Chromium Code Reviews| 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..67c33d9aee92fea607695133a3855ce376d6eb8e |
| --- /dev/null |
| +++ b/content/renderer/media/rtc_video_decoder.h |
| @@ -0,0 +1,115 @@ |
| +// 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/lock.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() |
|
Pawel Osciak
2013/05/15 17:26:32
s/likes/like
wuchengli
2013/05/23 16:50:47
Done.
|
| +// 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_|. |
|
Ami GONE FROM CHROMIUM
2013/05/14 22:57:24
s/by/on/
wuchengli
2013/05/15 15:30:46
Done.
|
| +class CONTENT_EXPORT RTCVideoDecoder |
| + : NON_EXPORTED_BASE(public webrtc::VideoDecoder) { |
| + public: |
| + RTCVideoDecoder( |
| + media::VideoDecoder* video_decoder, |
|
Ami GONE FROM CHROMIUM
2013/05/14 22:57:24
Why isn't this taking a VDA* instead?
(see earli
|
| + const scoped_refptr<base::MessageLoopProxy>& message_loop); |
| + virtual ~RTCVideoDecoder(); |
| + |
| + // webrtc::VideoDecoder implementation. |
| + // Called on WebRTC DecodingThread. |
| + virtual int32_t InitDecode( |
| + const webrtc::VideoCodec* codecSettings, |
| + int32_t numberOfCores) OVERRIDE; |
| + // Called on WebRTC DecodingThread. |
| + virtual int32_t Decode( |
| + const webrtc::EncodedImage& inputImage, |
| + bool missingFrames, |
| + const webrtc::RTPFragmentationHeader* fragmentation, |
| + const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL, |
| + int64_t renderTimeMs = -1) OVERRIDE; |
| + // Called on WebRTC DecodingThread. |
| + virtual int32_t RegisterDecodeCompleteCallback( |
| + webrtc::DecodedImageCallback* callback) OVERRIDE; |
| + // Called on Chrome_libJingle_WorkerThread. |
| + virtual int32_t Release() OVERRIDE; |
| + // Called on Chrome_libJingle_WorkerThread. |
| + virtual int32_t Reset() OVERRIDE; |
| + |
| + private: |
| + void InitWeakPtr(); |
| + void OnUpdateStatistics(const media::PipelineStatistics& stats); |
| + void OnUpdatePipelineStatus(const media::PipelineStatus status); |
|
Pawel Osciak
2013/05/15 17:26:32
Is const needed for this enum?
|
| + void ReleaseComplete(); |
| + void ResetComplete(); |
| + void FrameReady( |
| + media::VideoDecoder::Status status, |
| + const scoped_refptr<media::VideoFrame>& frame); |
| + |
| + enum State { |
| + kUninitialized, |
| + kInitialized, |
| + kDecoding, |
| + }; |
| + |
| + // Underlying hardware accelerated video decoder. |
| + scoped_ptr<media::VideoDecoder> video_decoder_; |
|
Ami GONE FROM CHROMIUM
2013/05/14 22:57:24
scoped_ptr<> here implies ownership, but passing b
wuchengli
2013/05/15 15:30:46
Done.
|
| + |
| + // The message loop to run callbacks. This should be the same as the main |
|
Pawel Osciak
2013/05/15 17:26:32
s/callbacks/callbacks on/
wuchengli
2013/05/23 16:50:47
Done.
|
| + // 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(), |
|
Pawel Osciak
2013/05/15 17:26:32
s/wait/wait for/
wuchengli
2013/05/23 16:50:47
Done.
|
| + // and Reset() are blocking calls. |
| + base::WaitableEvent decoder_waiter_; |
| + |
| + // Video buffer stream. |
| + scoped_ptr<RTCDemuxerStream> stream_; |
| + |
| + // The size of the video frames. |
| + gfx::Size frame_size_; |
| + |
| + // Protects |state_| and |decoding_error_occurred_|. |
| + base::Lock lock_; |
| + |
| + // The state of RTCVideoDecoder (guarded by |lock_|). |
| + State state_; |
| + |
| + // Indicate a decoding error has occurred. This is read by WebRTC |
| + // DecodingThread and set by decoder_message_loop_ (guarded by |lock_|. |
|
Ami GONE FROM CHROMIUM
2013/05/14 22:57:24
missing close paren
wuchengli
2013/05/15 15:30:46
Done.
|
| + bool decoding_error_occurred_; |
|
Ami GONE FROM CHROMIUM
2013/05/14 22:57:24
Why not use state_ to indicate this?
wuchengli
2013/05/15 15:30:46
Done. Great suggestion.
|
| + |
| + base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; |
|
Ami GONE FROM CHROMIUM
2013/05/14 22:57:24
Doco that these live & die on the decoder_message_
wuchengli
2013/05/15 15:30:46
Done.
|
| + base::WeakPtr<RTCVideoDecoder> weak_this_; |
| + base::WeakPtr<RTCDemuxerStream> weak_stream_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |