content/media/omx/RtspOmxReader.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/omx/RtspOmxReader.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +#if !defined(RtspOmxReader_h_)
    1.10 +#define RtspOmxReader_h_
    1.11 +
    1.12 +#include "MediaResource.h"
    1.13 +#include "MediaDecoderReader.h"
    1.14 +#include "MediaOmxReader.h"
    1.15 +
    1.16 +namespace mozilla {
    1.17 +
    1.18 +namespace dom {
    1.19 +  class TimeRanges;
    1.20 +}
    1.21 +
    1.22 +class AbstractMediaDecoder;
    1.23 +class RtspMediaResource;
    1.24 +
    1.25 +/* RtspOmxReader is a subclass of MediaOmxReader.
    1.26 + * The major reason that RtspOmxReader inherit from MediaOmxReader is the
    1.27 + * same video/audio decoding logic we can reuse.
    1.28 + */
    1.29 +class RtspOmxReader : public MediaOmxReader
    1.30 +{
    1.31 +protected:
    1.32 +  // Provide a Rtsp extractor.
    1.33 +  nsresult InitOmxDecoder() MOZ_FINAL MOZ_OVERRIDE;
    1.34 +
    1.35 +public:
    1.36 +  RtspOmxReader(AbstractMediaDecoder* aDecoder)
    1.37 +    : MediaOmxReader(aDecoder) {
    1.38 +    MOZ_COUNT_CTOR(RtspOmxReader);
    1.39 +    NS_ASSERTION(mDecoder, "RtspOmxReader mDecoder is null.");
    1.40 +    NS_ASSERTION(mDecoder->GetResource(),
    1.41 +                 "RtspOmxReader mDecoder->GetResource() is null.");
    1.42 +    mRtspResource = mDecoder->GetResource()->GetRtspPointer();
    1.43 +    MOZ_ASSERT(mRtspResource);
    1.44 +  }
    1.45 +
    1.46 +  virtual ~RtspOmxReader() MOZ_OVERRIDE {
    1.47 +    MOZ_COUNT_DTOR(RtspOmxReader);
    1.48 +  }
    1.49 +
    1.50 +  virtual nsresult ReadMetadata(MediaInfo* aInfo,
    1.51 +                                MetadataTags** aTags) MOZ_OVERRIDE;
    1.52 +
    1.53 +  // Implement a time-based seek instead of byte-based..
    1.54 +  virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime,
    1.55 +                        int64_t aCurrentTime) MOZ_FINAL MOZ_OVERRIDE;
    1.56 +
    1.57 +  // Override GetBuffered() to do nothing for below reasons:
    1.58 +  // 1. Because the Rtsp stream is a/v separated. The buffered data in a/v
    1.59 +  // tracks are not consistent with time stamp.
    1.60 +  // For example: audio buffer: 1~2s, video buffer: 1.5~2.5s
    1.61 +  // 2. Since the Rtsp is a realtime streaming, the buffer we made for
    1.62 +  // RtspMediaResource is quite small. The small buffer implies the time ranges
    1.63 +  // we returned are not useful for the MediaDecodeStateMachine. Unlike the
    1.64 +  // ChannelMediaResource, it has a "cache" that can store the whole streaming
    1.65 +  // data so the |GetBuffered| function can retrieve useful time ranges.
    1.66 +  virtual nsresult GetBuffered(mozilla::dom::TimeRanges* aBuffered,
    1.67 +                               int64_t aStartTime) MOZ_FINAL MOZ_OVERRIDE {
    1.68 +    return NS_OK;
    1.69 +  }
    1.70 +
    1.71 +  virtual void SetIdle() MOZ_OVERRIDE;
    1.72 +  virtual void SetActive() MOZ_OVERRIDE;
    1.73 +
    1.74 +private:
    1.75 +  // A pointer to RtspMediaResource for calling the Rtsp specific function.
    1.76 +  // The lifetime of mRtspResource is controlled by MediaDecoder. MediaDecoder
    1.77 +  // holds the MediaDecoderStateMachine and RtspMediaResource.
    1.78 +  // And MediaDecoderStateMachine holds this RtspOmxReader.
    1.79 +  RtspMediaResource* mRtspResource;
    1.80 +};
    1.81 +
    1.82 +} // namespace mozilla
    1.83 +
    1.84 +#endif

mercurial