| Index: content/renderer/media/rtc_video_decoder.h
|
| diff --git a/content/renderer/media/rtc_video_decoder.h b/content/renderer/media/rtc_video_decoder.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e8054b7f618d6b70c80977daf80d3a93d823807d
|
| --- /dev/null
|
| +++ b/content/renderer/media/rtc_video_decoder.h
|
| @@ -0,0 +1,107 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
|
| +#define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/synchronization/waitable_event.h"
|
| +#include "content/common/content_export.h"
|
| +#include "media/base/pipeline_status.h"
|
| +#include "media/base/video_decoder.h"
|
| +#include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
|
| +
|
| +namespace base {
|
| +class MessageLoopProxy;
|
| +};
|
| +
|
| +namespace content {
|
| +
|
| +class RTCDemuxerStream;
|
| +
|
| +// This class uses hardware accelerated video decoder to decode video for
|
| +// WebRTC. The message loop passed to the constructor should be the same one for
|
| +// GpuVideoDecoder. webrtc::VideoDecoder methods likes InitDecode() or Decode()
|
| +// are called by a different thread and should trampoline to
|
| +// |decoder_message_loop_|. Decode() is non-blocking and WebRTC calls it to
|
| +// queue the encoded image buffers. Decoded frames are delivered to decode
|
| +// complete callback by |decoder_message_loop_|.
|
| +class CONTENT_EXPORT RTCVideoDecoder
|
| + : NON_EXPORTED_BASE(public webrtc::VideoDecoder) {
|
| + public:
|
| + RTCVideoDecoder(
|
| + media::VideoDecoder* video_decoder,
|
| + const scoped_refptr<base::MessageLoopProxy>& message_loop);
|
| + virtual ~RTCVideoDecoder();
|
| +
|
| + // webrtc::VideoDecoder implementation.
|
| + virtual int32_t InitDecode(
|
| + const webrtc::VideoCodec* codecSettings,
|
| + int32_t numberOfCores) OVERRIDE;
|
| + virtual int32_t Decode(
|
| + const webrtc::EncodedImage& inputImage,
|
| + bool missingFrames,
|
| + const webrtc::RTPFragmentationHeader* fragmentation,
|
| + const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL,
|
| + int64_t renderTimeMs = -1) OVERRIDE;
|
| + virtual int32_t RegisterDecodeCompleteCallback(
|
| + webrtc::DecodedImageCallback* callback) OVERRIDE;
|
| + virtual int32_t Release() OVERRIDE;
|
| + virtual int32_t Reset() OVERRIDE;
|
| +
|
| + private:
|
| + void InitWeakPtr();
|
| + void OnUpdateStatistics(const media::PipelineStatistics& stats);
|
| + void OnUpdatePipelineStatus(const media::PipelineStatus status);
|
| + void ReleaseComplete();
|
| + void ResetComplete();
|
| + void FrameReady(
|
| + media::VideoDecoder::Status status,
|
| + const scoped_refptr<media::VideoFrame>& frame);
|
| + void RequestFrame();
|
| +
|
| + enum State {
|
| + kUninitialized,
|
| + kInitialized,
|
| + kDecoding,
|
| + };
|
| +
|
| + // Underlying hardware accelerated video decoder.
|
| + scoped_ptr<media::VideoDecoder> video_decoder_;
|
| +
|
| + // The message loop to run callbacks. This should be the same as the main
|
| + // message loop in GpuVideoDecoder.
|
| + scoped_refptr<base::MessageLoopProxy> decoder_message_loop_;
|
| +
|
| + webrtc::DecodedImageCallback* decode_complete_callback_;
|
| + media::PipelineStatus pipeline_status_;
|
| +
|
| + // Used to wait GpuVideoDecoder calls to complete. InitDecode(), Release(),
|
| + // and Reset() are blocking calls.
|
| + base::WaitableEvent decoder_waiter_;
|
| +
|
| + // Video buffer stream.
|
| + scoped_ptr<RTCDemuxerStream> stream_;
|
| +
|
| + // The size of the video frames.
|
| + gfx::Size size_;
|
| +
|
| + // The state of RTCVideoDecoder.
|
| + State state_;
|
| +
|
| + base::WeakPtrFactory<RTCVideoDecoder> weak_factory_;
|
| + base::WeakPtr<RTCVideoDecoder> weak_this_;
|
| + base::WeakPtr<RTCDemuxerStream> weak_stream_;
|
| +
|
| + // Indicate a decoding error has occurred. This is read by WebRTC
|
| + // DecodingThread and set by decoder_message_loop_.
|
| + volatile bool decoding_error_occurred_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
|
|
|