Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/weak_ptr.h" | |
| 10 #include "base/synchronization/lock.h" | |
| 11 #include "base/synchronization/waitable_event.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 #include "media/base/pipeline_status.h" | |
| 14 #include "media/base/video_decoder.h" | |
| 15 #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_i nterface.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class MessageLoopProxy; | |
| 19 }; | |
| 20 | |
| 21 namespace content { | |
| 22 | |
| 23 class RTCDemuxerStream; | |
| 24 | |
| 25 // This class uses hardware accelerated video decoder to decode video for | |
| 26 // WebRTC. The message loop passed to the constructor should be the same one for | |
| 27 // 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.
| |
| 28 // are called by a different thread and should trampoline to | |
| 29 // |decoder_message_loop_|. Decode() is non-blocking and WebRTC calls it to | |
| 30 // queue the encoded image buffers. Decoded frames are delivered to decode | |
| 31 // 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.
| |
| 32 class CONTENT_EXPORT RTCVideoDecoder | |
| 33 : NON_EXPORTED_BASE(public webrtc::VideoDecoder) { | |
| 34 public: | |
| 35 RTCVideoDecoder( | |
| 36 media::VideoDecoder* video_decoder, | |
|
Ami GONE FROM CHROMIUM
2013/05/14 22:57:24
Why isn't this taking a VDA* instead?
(see earli
| |
| 37 const scoped_refptr<base::MessageLoopProxy>& message_loop); | |
| 38 virtual ~RTCVideoDecoder(); | |
| 39 | |
| 40 // webrtc::VideoDecoder implementation. | |
| 41 // Called on WebRTC DecodingThread. | |
| 42 virtual int32_t InitDecode( | |
| 43 const webrtc::VideoCodec* codecSettings, | |
| 44 int32_t numberOfCores) OVERRIDE; | |
| 45 // Called on WebRTC DecodingThread. | |
| 46 virtual int32_t Decode( | |
| 47 const webrtc::EncodedImage& inputImage, | |
| 48 bool missingFrames, | |
| 49 const webrtc::RTPFragmentationHeader* fragmentation, | |
| 50 const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL, | |
| 51 int64_t renderTimeMs = -1) OVERRIDE; | |
| 52 // Called on WebRTC DecodingThread. | |
| 53 virtual int32_t RegisterDecodeCompleteCallback( | |
| 54 webrtc::DecodedImageCallback* callback) OVERRIDE; | |
| 55 // Called on Chrome_libJingle_WorkerThread. | |
| 56 virtual int32_t Release() OVERRIDE; | |
| 57 // Called on Chrome_libJingle_WorkerThread. | |
| 58 virtual int32_t Reset() OVERRIDE; | |
| 59 | |
| 60 private: | |
| 61 void InitWeakPtr(); | |
| 62 void OnUpdateStatistics(const media::PipelineStatistics& stats); | |
| 63 void OnUpdatePipelineStatus(const media::PipelineStatus status); | |
|
Pawel Osciak
2013/05/15 17:26:32
Is const needed for this enum?
| |
| 64 void ReleaseComplete(); | |
| 65 void ResetComplete(); | |
| 66 void FrameReady( | |
| 67 media::VideoDecoder::Status status, | |
| 68 const scoped_refptr<media::VideoFrame>& frame); | |
| 69 | |
| 70 enum State { | |
| 71 kUninitialized, | |
| 72 kInitialized, | |
| 73 kDecoding, | |
| 74 }; | |
| 75 | |
| 76 // Underlying hardware accelerated video decoder. | |
| 77 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.
| |
| 78 | |
| 79 // 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.
| |
| 80 // message loop in GpuVideoDecoder. | |
| 81 scoped_refptr<base::MessageLoopProxy> decoder_message_loop_; | |
| 82 | |
| 83 webrtc::DecodedImageCallback* decode_complete_callback_; | |
| 84 media::PipelineStatus pipeline_status_; | |
| 85 | |
| 86 // 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.
| |
| 87 // and Reset() are blocking calls. | |
| 88 base::WaitableEvent decoder_waiter_; | |
| 89 | |
| 90 // Video buffer stream. | |
| 91 scoped_ptr<RTCDemuxerStream> stream_; | |
| 92 | |
| 93 // The size of the video frames. | |
| 94 gfx::Size frame_size_; | |
| 95 | |
| 96 // Protects |state_| and |decoding_error_occurred_|. | |
| 97 base::Lock lock_; | |
| 98 | |
| 99 // The state of RTCVideoDecoder (guarded by |lock_|). | |
| 100 State state_; | |
| 101 | |
| 102 // Indicate a decoding error has occurred. This is read by WebRTC | |
| 103 // 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.
| |
| 104 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.
| |
| 105 | |
| 106 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.
| |
| 107 base::WeakPtr<RTCVideoDecoder> weak_this_; | |
| 108 base::WeakPtr<RTCDemuxerStream> weak_stream_; | |
| 109 | |
| 110 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | |
| 111 }; | |
| 112 | |
| 113 } // namespace content | |
| 114 | |
| 115 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | |
| OLD | NEW |