Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <deque> | 7 #include <deque> |
| 8 | 8 |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "media/base/callback.h" | 10 #include "media/base/callback.h" |
| 11 #include "media/base/filter_host.h" | 11 #include "media/base/filter_host.h" |
| 12 #include "media/base/filters.h" | 12 #include "media/base/filters.h" |
| 13 #include "media/base/limits.h" | 13 #include "media/base/limits.h" |
| 14 #include "media/base/media_format.h" | |
| 15 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
| 16 | 15 |
| 17 using media::DemuxerStream; | 16 using media::DemuxerStream; |
| 18 using media::FilterCallback; | 17 using media::FilterCallback; |
| 19 using media::FilterStatusCB; | 18 using media::FilterStatusCB; |
| 20 using media::kNoTimestamp; | 19 using media::kNoTimestamp; |
| 21 using media::Limits; | 20 using media::Limits; |
| 22 using media::MediaFormat; | |
| 23 using media::PIPELINE_OK; | 21 using media::PIPELINE_OK; |
| 24 using media::StatisticsCallback; | 22 using media::StatisticsCallback; |
| 25 using media::VideoDecoder; | 23 using media::VideoDecoder; |
| 26 using media::VideoFrame; | 24 using media::VideoFrame; |
| 27 | 25 |
| 28 RTCVideoDecoder::RTCVideoDecoder(MessageLoop* message_loop, | 26 RTCVideoDecoder::RTCVideoDecoder(MessageLoop* message_loop, |
| 29 const std::string& url) | 27 const std::string& url) |
| 30 : message_loop_(message_loop), | 28 : message_loop_(message_loop), |
| 31 width_(176), | 29 width_(176), |
| 32 height_(144), | 30 height_(144), |
| 33 url_(url), | 31 url_(url), |
| 34 state_(kUnInitialized) { | 32 state_(kUnInitialized) { |
| 35 } | 33 } |
| 36 | 34 |
| 37 RTCVideoDecoder::~RTCVideoDecoder() { | 35 RTCVideoDecoder::~RTCVideoDecoder() {} |
| 38 } | |
| 39 | 36 |
| 40 void RTCVideoDecoder::Initialize(DemuxerStream* demuxer_stream, | 37 void RTCVideoDecoder::Initialize(DemuxerStream* demuxer_stream, |
| 41 FilterCallback* filter_callback, | 38 FilterCallback* filter_callback, |
| 42 StatisticsCallback* stat_callback) { | 39 StatisticsCallback* stat_callback) { |
| 43 if (MessageLoop::current() != message_loop_) { | 40 if (MessageLoop::current() != message_loop_) { |
| 44 message_loop_->PostTask( | 41 message_loop_->PostTask( |
| 45 FROM_HERE, | 42 FROM_HERE, |
| 46 NewRunnableMethod(this, | 43 NewRunnableMethod(this, |
| 47 &RTCVideoDecoder::Initialize, | 44 &RTCVideoDecoder::Initialize, |
| 48 make_scoped_refptr(demuxer_stream), | 45 make_scoped_refptr(demuxer_stream), |
| 49 filter_callback, stat_callback)); | 46 filter_callback, stat_callback)); |
| 50 return; | 47 return; |
| 51 } | 48 } |
| 52 | 49 |
| 53 DCHECK_EQ(MessageLoop::current(), message_loop_); | 50 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 54 | 51 |
| 55 lock_.Acquire(); | 52 lock_.Acquire(); |
| 56 frame_queue_available_.clear(); | 53 frame_queue_available_.clear(); |
| 57 lock_.Release(); | 54 lock_.Release(); |
| 58 media_format_.SetAsInteger(MediaFormat::kWidth, width_); | |
| 59 media_format_.SetAsInteger(MediaFormat::kHeight, height_); | |
| 60 media_format_.SetAsInteger(MediaFormat::kSurfaceType, | |
| 61 static_cast<int>(VideoFrame::YV12)); | |
| 62 | 55 |
| 63 state_ = kNormal; | 56 state_ = kNormal; |
| 64 | 57 |
| 65 filter_callback->Run(); | 58 filter_callback->Run(); |
| 66 delete filter_callback; | 59 delete filter_callback; |
| 67 | 60 |
| 68 // TODO(acolwell): Implement stats. | 61 // TODO(acolwell): Implement stats. |
| 69 delete stat_callback; | 62 delete stat_callback; |
| 70 } | 63 } |
| 71 | 64 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 // so that the renderer can complete the seeking | 123 // so that the renderer can complete the seeking |
| 131 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { | 124 for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) { |
| 132 VideoFrameReady(VideoFrame::CreateBlackFrame(width_, height_)); | 125 VideoFrameReady(VideoFrame::CreateBlackFrame(width_, height_)); |
| 133 } | 126 } |
| 134 | 127 |
| 135 state_ = kNormal; | 128 state_ = kNormal; |
| 136 | 129 |
| 137 cb.Run(PIPELINE_OK); | 130 cb.Run(PIPELINE_OK); |
| 138 } | 131 } |
| 139 | 132 |
| 140 const MediaFormat& RTCVideoDecoder::media_format() { | |
| 141 return media_format_; | |
| 142 } | |
| 143 | |
| 144 void RTCVideoDecoder::ProduceVideoFrame( | 133 void RTCVideoDecoder::ProduceVideoFrame( |
| 145 scoped_refptr<VideoFrame> video_frame) { | 134 scoped_refptr<VideoFrame> video_frame) { |
| 146 if (MessageLoop::current() != message_loop_) { | 135 if (MessageLoop::current() != message_loop_) { |
| 147 message_loop_->PostTask( | 136 message_loop_->PostTask( |
| 148 FROM_HERE, | 137 FROM_HERE, |
| 149 NewRunnableMethod(this, | 138 NewRunnableMethod(this, |
| 150 &RTCVideoDecoder::ProduceVideoFrame, video_frame)); | 139 &RTCVideoDecoder::ProduceVideoFrame, video_frame)); |
| 151 return; | 140 return; |
| 152 } | 141 } |
| 153 DCHECK_EQ(MessageLoop::current(), message_loop_); | 142 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 154 base::AutoLock auto_lock(lock_); | 143 base::AutoLock auto_lock(lock_); |
| 155 frame_queue_available_.push_back(video_frame); | 144 frame_queue_available_.push_back(video_frame); |
| 156 } | 145 } |
| 157 | 146 |
| 158 bool RTCVideoDecoder::ProvidesBuffer() { | 147 bool RTCVideoDecoder::ProvidesBuffer() { |
| 159 return true; | 148 return true; |
| 160 } | 149 } |
| 161 | 150 |
| 151 int RTCVideoDecoder::width() { | |
| 152 return width_; | |
| 153 } | |
| 154 | |
| 155 int RTCVideoDecoder::height() { | |
| 156 return height_; | |
| 157 } | |
| 158 | |
| 162 bool RTCVideoDecoder::SetSize(int width, int height, int reserved) { | 159 bool RTCVideoDecoder::SetSize(int width, int height, int reserved) { |
| 163 width_ = width; | 160 width_ = width; |
|
Ami GONE FROM CHROMIUM
2011/07/20 16:30:22
Before this CL, width/height changes through calls
scherkus (not reviewing)
2011/07/20 16:51:52
Don't the lines I removed below reflect width/heig
Ami GONE FROM CHROMIUM
2011/07/20 16:56:26
D'oh. Yep. nm.
| |
| 164 height_ = height; | 161 height_ = height; |
| 165 | 162 |
| 166 media_format_.SetAsInteger(MediaFormat::kWidth, width_); | |
| 167 media_format_.SetAsInteger(MediaFormat::kHeight, height_); | |
| 168 host()->SetVideoSize(width_, height_); | 163 host()->SetVideoSize(width_, height_); |
| 169 return true; | 164 return true; |
| 170 } | 165 } |
| 171 | 166 |
| 172 bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) { | 167 bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) { |
| 173 DCHECK(frame); | 168 DCHECK(frame); |
| 174 | 169 |
| 175 if (state_ != kNormal) | 170 if (state_ != kNormal) |
| 176 return true; | 171 return true; |
| 177 | 172 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 FROM_HERE, | 222 FROM_HERE, |
| 228 NewRunnableMethod(this, | 223 NewRunnableMethod(this, |
| 229 &RTCVideoDecoder::VideoFrameReady, | 224 &RTCVideoDecoder::VideoFrameReady, |
| 230 video_frame)); | 225 video_frame)); |
| 231 } else { | 226 } else { |
| 232 VideoFrameReady(video_frame); | 227 VideoFrameReady(video_frame); |
| 233 } | 228 } |
| 234 | 229 |
| 235 return true; | 230 return true; |
| 236 } | 231 } |
| OLD | NEW |