Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/rtc_video_decoder.h" | 5 #include "content/renderer/media/rtc_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 scoped_ptr<RTCVideoDecoder> RTCVideoDecoder::Create( | 109 scoped_ptr<RTCVideoDecoder> RTCVideoDecoder::Create( |
| 110 webrtc::VideoCodecType type, | 110 webrtc::VideoCodecType type, |
| 111 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories) { | 111 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories) { |
| 112 scoped_ptr<RTCVideoDecoder> decoder; | 112 scoped_ptr<RTCVideoDecoder> decoder; |
| 113 // Convert WebRTC codec type to media codec profile. | 113 // Convert WebRTC codec type to media codec profile. |
| 114 media::VideoCodecProfile profile; | 114 media::VideoCodecProfile profile; |
| 115 switch (type) { | 115 switch (type) { |
| 116 case webrtc::kVideoCodecVP8: | 116 case webrtc::kVideoCodecVP8: |
| 117 profile = media::VP8PROFILE_MAIN; | 117 profile = media::VP8PROFILE_MAIN; |
| 118 break; | 118 break; |
| 119 case webrtc::kVideoCodecH264: | |
| 120 profile = media::H264PROFILE_MAIN; | |
| 121 break; | |
| 119 default: | 122 default: |
| 120 DVLOG(2) << "Video codec not supported:" << type; | 123 DVLOG(2) << "Video codec not supported:" << type; |
| 121 return decoder.Pass(); | 124 return decoder.Pass(); |
| 122 } | 125 } |
| 123 | 126 |
| 124 base::WaitableEvent waiter(true, false); | 127 base::WaitableEvent waiter(true, false); |
| 125 decoder.reset(new RTCVideoDecoder(factories)); | 128 decoder.reset(new RTCVideoDecoder(factories)); |
| 126 decoder->factories_->GetTaskRunner()->PostTask( | 129 decoder->factories_->GetTaskRunner()->PostTask( |
| 127 FROM_HERE, | 130 FROM_HERE, |
| 128 base::Bind(&RTCVideoDecoder::CreateVDA, | 131 base::Bind(&RTCVideoDecoder::CreateVDA, |
| 129 base::Unretained(decoder.get()), | 132 base::Unretained(decoder.get()), |
| 130 profile, | 133 profile, |
| 131 &waiter)); | 134 &waiter)); |
| 132 waiter.Wait(); | 135 waiter.Wait(); |
| 133 // vda can be NULL if VP8 is not supported. | 136 // vda can be NULL if VP8 is not supported. |
| 134 if (decoder->vda_ != NULL) { | 137 if (decoder->vda_ != NULL) { |
| 135 decoder->state_ = INITIALIZED; | 138 decoder->state_ = INITIALIZED; |
| 136 } else { | 139 } else { |
| 137 factories->GetTaskRunner()->DeleteSoon(FROM_HERE, decoder.release()); | 140 factories->GetTaskRunner()->DeleteSoon(FROM_HERE, decoder.release()); |
| 138 } | 141 } |
| 139 return decoder.Pass(); | 142 return decoder.Pass(); |
| 140 } | 143 } |
| 141 | 144 |
| 142 int32_t RTCVideoDecoder::InitDecode(const webrtc::VideoCodec* codecSettings, | 145 int32_t RTCVideoDecoder::InitDecode(const webrtc::VideoCodec* codecSettings, |
| 143 int32_t /*numberOfCores*/) { | 146 int32_t /*numberOfCores*/) { |
| 144 DVLOG(2) << "InitDecode"; | 147 DVLOG(2) << "InitDecode"; |
| 145 DCHECK_EQ(codecSettings->codecType, webrtc::kVideoCodecVP8); | 148 DCHECK(codecSettings->codecType == webrtc::kVideoCodecVP8 || |
|
Pawel Osciak
2014/08/10 00:30:29
We should verify against the type passed to Create
hshi1
2014/08/12 01:06:55
Done (requires passing |type| to ctor of RTCVD).
| |
| 146 if (codecSettings->codecSpecific.VP8.feedbackModeOn) { | 149 codecSettings->codecType == webrtc::kVideoCodecH264); |
| 150 if (codecSettings->codecType == webrtc::kVideoCodecVP8 && | |
| 151 codecSettings->codecSpecific.VP8.feedbackModeOn) { | |
| 147 LOG(ERROR) << "Feedback mode not supported"; | 152 LOG(ERROR) << "Feedback mode not supported"; |
| 148 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_ERROR); | 153 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_ERROR); |
| 149 } | 154 } |
| 150 | 155 |
| 151 base::AutoLock auto_lock(lock_); | 156 base::AutoLock auto_lock(lock_); |
| 152 if (state_ == UNINITIALIZED || state_ == DECODE_ERROR) { | 157 if (state_ == UNINITIALIZED || state_ == DECODE_ERROR) { |
| 153 LOG(ERROR) << "VDA is not initialized. state=" << state_; | 158 LOG(ERROR) << "VDA is not initialized. state=" << state_; |
| 154 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_UNINITIALIZED); | 159 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_UNINITIALIZED); |
| 155 } | 160 } |
| 156 // Create some shared memory if the queue is empty. | 161 // Create some shared memory if the queue is empty. |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 796 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); | 801 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); |
| 797 return status; | 802 return status; |
| 798 } | 803 } |
| 799 | 804 |
| 800 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 805 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 801 const { | 806 const { |
| 802 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 807 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 803 } | 808 } |
| 804 | 809 |
| 805 } // namespace content | 810 } // namespace content |
| OLD | NEW |