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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 size_t size) | 64 size_t size) |
65 : bitstream_buffer_id(bitstream_buffer_id), | 65 : bitstream_buffer_id(bitstream_buffer_id), |
66 timestamp(timestamp), | 66 timestamp(timestamp), |
67 size(size) {} | 67 size(size) {} |
68 | 68 |
69 RTCVideoDecoder::BufferData::BufferData() {} | 69 RTCVideoDecoder::BufferData::BufferData() {} |
70 | 70 |
71 RTCVideoDecoder::BufferData::~BufferData() {} | 71 RTCVideoDecoder::BufferData::~BufferData() {} |
72 | 72 |
73 RTCVideoDecoder::RTCVideoDecoder( | 73 RTCVideoDecoder::RTCVideoDecoder( |
| 74 webrtc::VideoCodecType type, |
74 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories) | 75 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories) |
75 : factories_(factories), | 76 : video_codec_type_(type), |
| 77 factories_(factories), |
76 decoder_texture_target_(0), | 78 decoder_texture_target_(0), |
77 next_picture_buffer_id_(0), | 79 next_picture_buffer_id_(0), |
78 state_(UNINITIALIZED), | 80 state_(UNINITIALIZED), |
79 decode_complete_callback_(NULL), | 81 decode_complete_callback_(NULL), |
80 num_shm_buffers_(0), | 82 num_shm_buffers_(0), |
81 next_bitstream_buffer_id_(0), | 83 next_bitstream_buffer_id_(0), |
82 reset_bitstream_buffer_id_(ID_INVALID), | 84 reset_bitstream_buffer_id_(ID_INVALID), |
83 weak_factory_(this) { | 85 weak_factory_(this) { |
84 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); | 86 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); |
85 } | 87 } |
(...skipping 23 matching lines...) Expand all Loading... |
109 scoped_ptr<RTCVideoDecoder> RTCVideoDecoder::Create( | 111 scoped_ptr<RTCVideoDecoder> RTCVideoDecoder::Create( |
110 webrtc::VideoCodecType type, | 112 webrtc::VideoCodecType type, |
111 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories) { | 113 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories) { |
112 scoped_ptr<RTCVideoDecoder> decoder; | 114 scoped_ptr<RTCVideoDecoder> decoder; |
113 // Convert WebRTC codec type to media codec profile. | 115 // Convert WebRTC codec type to media codec profile. |
114 media::VideoCodecProfile profile; | 116 media::VideoCodecProfile profile; |
115 switch (type) { | 117 switch (type) { |
116 case webrtc::kVideoCodecVP8: | 118 case webrtc::kVideoCodecVP8: |
117 profile = media::VP8PROFILE_MAIN; | 119 profile = media::VP8PROFILE_MAIN; |
118 break; | 120 break; |
| 121 case webrtc::kVideoCodecH264: |
| 122 profile = media::H264PROFILE_MAIN; |
| 123 break; |
119 default: | 124 default: |
120 DVLOG(2) << "Video codec not supported:" << type; | 125 DVLOG(2) << "Video codec not supported:" << type; |
121 return decoder.Pass(); | 126 return decoder.Pass(); |
122 } | 127 } |
123 | 128 |
124 base::WaitableEvent waiter(true, false); | 129 base::WaitableEvent waiter(true, false); |
125 decoder.reset(new RTCVideoDecoder(factories)); | 130 decoder.reset(new RTCVideoDecoder(type, factories)); |
126 decoder->factories_->GetTaskRunner()->PostTask( | 131 decoder->factories_->GetTaskRunner()->PostTask( |
127 FROM_HERE, | 132 FROM_HERE, |
128 base::Bind(&RTCVideoDecoder::CreateVDA, | 133 base::Bind(&RTCVideoDecoder::CreateVDA, |
129 base::Unretained(decoder.get()), | 134 base::Unretained(decoder.get()), |
130 profile, | 135 profile, |
131 &waiter)); | 136 &waiter)); |
132 waiter.Wait(); | 137 waiter.Wait(); |
133 // vda can be NULL if VP8 is not supported. | 138 // vda can be NULL if VP8 is not supported. |
134 if (decoder->vda_ != NULL) { | 139 if (decoder->vda_ != NULL) { |
135 decoder->state_ = INITIALIZED; | 140 decoder->state_ = INITIALIZED; |
136 } else { | 141 } else { |
137 factories->GetTaskRunner()->DeleteSoon(FROM_HERE, decoder.release()); | 142 factories->GetTaskRunner()->DeleteSoon(FROM_HERE, decoder.release()); |
138 } | 143 } |
139 return decoder.Pass(); | 144 return decoder.Pass(); |
140 } | 145 } |
141 | 146 |
142 int32_t RTCVideoDecoder::InitDecode(const webrtc::VideoCodec* codecSettings, | 147 int32_t RTCVideoDecoder::InitDecode(const webrtc::VideoCodec* codecSettings, |
143 int32_t /*numberOfCores*/) { | 148 int32_t /*numberOfCores*/) { |
144 DVLOG(2) << "InitDecode"; | 149 DVLOG(2) << "InitDecode"; |
145 DCHECK_EQ(codecSettings->codecType, webrtc::kVideoCodecVP8); | 150 DCHECK(video_codec_type_ == codecSettings->codecType); |
146 if (codecSettings->codecSpecific.VP8.feedbackModeOn) { | 151 if (codecSettings->codecType == webrtc::kVideoCodecVP8 && |
| 152 codecSettings->codecSpecific.VP8.feedbackModeOn) { |
147 LOG(ERROR) << "Feedback mode not supported"; | 153 LOG(ERROR) << "Feedback mode not supported"; |
148 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_ERROR); | 154 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_ERROR); |
149 } | 155 } |
150 | 156 |
151 base::AutoLock auto_lock(lock_); | 157 base::AutoLock auto_lock(lock_); |
152 if (state_ == UNINITIALIZED || state_ == DECODE_ERROR) { | 158 if (state_ == UNINITIALIZED || state_ == DECODE_ERROR) { |
153 LOG(ERROR) << "VDA is not initialized. state=" << state_; | 159 LOG(ERROR) << "VDA is not initialized. state=" << state_; |
154 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_UNINITIALIZED); | 160 return RecordInitDecodeUMA(WEBRTC_VIDEO_CODEC_UNINITIALIZED); |
155 } | 161 } |
156 // Create some shared memory if the queue is empty. | 162 // 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); | 802 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoDecoderInitDecodeSuccess", sample); |
797 return status; | 803 return status; |
798 } | 804 } |
799 | 805 |
800 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 806 void RTCVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
801 const { | 807 const { |
802 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 808 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
803 } | 809 } |
804 | 810 |
805 } // namespace content | 811 } // namespace content |
OLD | NEW |