Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #if !defined(RtspOmxReader_h_)
7 #define RtspOmxReader_h_
9 #include "MediaResource.h"
10 #include "MediaDecoderReader.h"
11 #include "MediaOmxReader.h"
13 namespace mozilla {
15 namespace dom {
16 class TimeRanges;
17 }
19 class AbstractMediaDecoder;
20 class RtspMediaResource;
22 /* RtspOmxReader is a subclass of MediaOmxReader.
23 * The major reason that RtspOmxReader inherit from MediaOmxReader is the
24 * same video/audio decoding logic we can reuse.
25 */
26 class RtspOmxReader : public MediaOmxReader
27 {
28 protected:
29 // Provide a Rtsp extractor.
30 nsresult InitOmxDecoder() MOZ_FINAL MOZ_OVERRIDE;
32 public:
33 RtspOmxReader(AbstractMediaDecoder* aDecoder)
34 : MediaOmxReader(aDecoder) {
35 MOZ_COUNT_CTOR(RtspOmxReader);
36 NS_ASSERTION(mDecoder, "RtspOmxReader mDecoder is null.");
37 NS_ASSERTION(mDecoder->GetResource(),
38 "RtspOmxReader mDecoder->GetResource() is null.");
39 mRtspResource = mDecoder->GetResource()->GetRtspPointer();
40 MOZ_ASSERT(mRtspResource);
41 }
43 virtual ~RtspOmxReader() MOZ_OVERRIDE {
44 MOZ_COUNT_DTOR(RtspOmxReader);
45 }
47 virtual nsresult ReadMetadata(MediaInfo* aInfo,
48 MetadataTags** aTags) MOZ_OVERRIDE;
50 // Implement a time-based seek instead of byte-based..
51 virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
52 int64_t aCurrentTime) MOZ_FINAL MOZ_OVERRIDE;
54 // Override GetBuffered() to do nothing for below reasons:
55 // 1. Because the Rtsp stream is a/v separated. The buffered data in a/v
56 // tracks are not consistent with time stamp.
57 // For example: audio buffer: 1~2s, video buffer: 1.5~2.5s
58 // 2. Since the Rtsp is a realtime streaming, the buffer we made for
59 // RtspMediaResource is quite small. The small buffer implies the time ranges
60 // we returned are not useful for the MediaDecodeStateMachine. Unlike the
61 // ChannelMediaResource, it has a "cache" that can store the whole streaming
62 // data so the |GetBuffered| function can retrieve useful time ranges.
63 virtual nsresult GetBuffered(mozilla::dom::TimeRanges* aBuffered,
64 int64_t aStartTime) MOZ_FINAL MOZ_OVERRIDE {
65 return NS_OK;
66 }
68 virtual void SetIdle() MOZ_OVERRIDE;
69 virtual void SetActive() MOZ_OVERRIDE;
71 private:
72 // A pointer to RtspMediaResource for calling the Rtsp specific function.
73 // The lifetime of mRtspResource is controlled by MediaDecoder. MediaDecoder
74 // holds the MediaDecoderStateMachine and RtspMediaResource.
75 // And MediaDecoderStateMachine holds this RtspOmxReader.
76 RtspMediaResource* mRtspResource;
77 };
79 } // namespace mozilla
81 #endif