michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #if !defined(RtspOmxReader_h_) michael@0: #define RtspOmxReader_h_ michael@0: michael@0: #include "MediaResource.h" michael@0: #include "MediaDecoderReader.h" michael@0: #include "MediaOmxReader.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace dom { michael@0: class TimeRanges; michael@0: } michael@0: michael@0: class AbstractMediaDecoder; michael@0: class RtspMediaResource; michael@0: michael@0: /* RtspOmxReader is a subclass of MediaOmxReader. michael@0: * The major reason that RtspOmxReader inherit from MediaOmxReader is the michael@0: * same video/audio decoding logic we can reuse. michael@0: */ michael@0: class RtspOmxReader : public MediaOmxReader michael@0: { michael@0: protected: michael@0: // Provide a Rtsp extractor. michael@0: nsresult InitOmxDecoder() MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: public: michael@0: RtspOmxReader(AbstractMediaDecoder* aDecoder) michael@0: : MediaOmxReader(aDecoder) { michael@0: MOZ_COUNT_CTOR(RtspOmxReader); michael@0: NS_ASSERTION(mDecoder, "RtspOmxReader mDecoder is null."); michael@0: NS_ASSERTION(mDecoder->GetResource(), michael@0: "RtspOmxReader mDecoder->GetResource() is null."); michael@0: mRtspResource = mDecoder->GetResource()->GetRtspPointer(); michael@0: MOZ_ASSERT(mRtspResource); michael@0: } michael@0: michael@0: virtual ~RtspOmxReader() MOZ_OVERRIDE { michael@0: MOZ_COUNT_DTOR(RtspOmxReader); michael@0: } michael@0: michael@0: virtual nsresult ReadMetadata(MediaInfo* aInfo, michael@0: MetadataTags** aTags) MOZ_OVERRIDE; michael@0: michael@0: // Implement a time-based seek instead of byte-based.. michael@0: virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, michael@0: int64_t aCurrentTime) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: // Override GetBuffered() to do nothing for below reasons: michael@0: // 1. Because the Rtsp stream is a/v separated. The buffered data in a/v michael@0: // tracks are not consistent with time stamp. michael@0: // For example: audio buffer: 1~2s, video buffer: 1.5~2.5s michael@0: // 2. Since the Rtsp is a realtime streaming, the buffer we made for michael@0: // RtspMediaResource is quite small. The small buffer implies the time ranges michael@0: // we returned are not useful for the MediaDecodeStateMachine. Unlike the michael@0: // ChannelMediaResource, it has a "cache" that can store the whole streaming michael@0: // data so the |GetBuffered| function can retrieve useful time ranges. michael@0: virtual nsresult GetBuffered(mozilla::dom::TimeRanges* aBuffered, michael@0: int64_t aStartTime) MOZ_FINAL MOZ_OVERRIDE { michael@0: return NS_OK; michael@0: } michael@0: michael@0: virtual void SetIdle() MOZ_OVERRIDE; michael@0: virtual void SetActive() MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: // A pointer to RtspMediaResource for calling the Rtsp specific function. michael@0: // The lifetime of mRtspResource is controlled by MediaDecoder. MediaDecoder michael@0: // holds the MediaDecoderStateMachine and RtspMediaResource. michael@0: // And MediaDecoderStateMachine holds this RtspOmxReader. michael@0: RtspMediaResource* mRtspResource; michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif