| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (!video_decoder_thread_->RunsTasksOnCurrentThread()) { | 95 if (!video_decoder_thread_->RunsTasksOnCurrentThread()) { |
| 96 video_decoder_thread_->PostTask( | 96 video_decoder_thread_->PostTask( |
| 97 FROM_HERE, base::Bind(&RTCVideoDecoder::Stop, this, closure)); | 97 FROM_HERE, base::Bind(&RTCVideoDecoder::Stop, this, closure)); |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 | 100 |
| 101 state_ = kStopped; | 101 state_ = kStopped; |
| 102 closure.Run(); | 102 closure.Run(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 const gfx::Size& RTCVideoDecoder::natural_size() { | |
| 106 // TODO(vrk): Return natural size when aspect ratio support is implemented. | |
| 107 return visible_size_; | |
| 108 } | |
| 109 | |
| 110 void RTCVideoDecoder::PrepareForShutdownHack() { | 105 void RTCVideoDecoder::PrepareForShutdownHack() { |
| 111 if (!video_decoder_thread_->RunsTasksOnCurrentThread()) { | 106 if (!video_decoder_thread_->RunsTasksOnCurrentThread()) { |
| 112 video_decoder_thread_->PostTask( | 107 video_decoder_thread_->PostTask( |
| 113 FROM_HERE, base::Bind(&RTCVideoDecoder::PrepareForShutdownHack, | 108 FROM_HERE, base::Bind(&RTCVideoDecoder::PrepareForShutdownHack, |
| 114 this)); | 109 this)); |
| 115 return; | 110 return; |
| 116 } | 111 } |
| 117 shutting_down_ = true; | 112 shutting_down_ = true; |
| 118 CancelPendingRead(); | 113 CancelPendingRead(); |
| 119 } | 114 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 got_first_frame_ = true; | 149 got_first_frame_ = true; |
| 155 } | 150 } |
| 156 | 151 |
| 157 // Always allocate a new frame. | 152 // Always allocate a new frame. |
| 158 // | 153 // |
| 159 // TODO(scherkus): migrate this to proper buffer recycling. | 154 // TODO(scherkus): migrate this to proper buffer recycling. |
| 160 scoped_refptr<media::VideoFrame> video_frame = | 155 scoped_refptr<media::VideoFrame> video_frame = |
| 161 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, | 156 media::VideoFrame::CreateFrame(media::VideoFrame::YV12, |
| 162 visible_size_.width(), | 157 visible_size_.width(), |
| 163 visible_size_.height(), | 158 visible_size_.height(), |
| 159 visible_size_, |
| 164 timestamp - start_time_); | 160 timestamp - start_time_); |
| 165 last_frame_timestamp_ = timestamp; | 161 last_frame_timestamp_ = timestamp; |
| 166 | 162 |
| 167 // Aspect ratio unsupported; DCHECK when there are non-square pixels. | 163 // Aspect ratio unsupported; DCHECK when there are non-square pixels. |
| 168 DCHECK_EQ(frame->GetPixelWidth(), 1u); | 164 DCHECK_EQ(frame->GetPixelWidth(), 1u); |
| 169 DCHECK_EQ(frame->GetPixelHeight(), 1u); | 165 DCHECK_EQ(frame->GetPixelHeight(), 1u); |
| 170 | 166 |
| 171 int y_rows = frame->GetHeight(); | 167 int y_rows = frame->GetHeight(); |
| 172 int uv_rows = frame->GetHeight() / 2; // YV12 format. | 168 int uv_rows = frame->GetHeight() / 2; // YV12 format. |
| 173 CopyYPlane(frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame); | 169 CopyYPlane(frame->GetYPlane(), frame->GetYPitch(), y_rows, video_frame); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 200 DCHECK(main_thread_->RunsTasksOnCurrentThread()); | 196 DCHECK(main_thread_->RunsTasksOnCurrentThread()); |
| 201 if (video_track_) { | 197 if (video_track_) { |
| 202 video_track_->RemoveRenderer(this); | 198 video_track_->RemoveRenderer(this); |
| 203 video_track_ = NULL; | 199 video_track_ = NULL; |
| 204 } | 200 } |
| 205 } | 201 } |
| 206 | 202 |
| 207 RTCVideoDecoder::~RTCVideoDecoder() { | 203 RTCVideoDecoder::~RTCVideoDecoder() { |
| 208 DCHECK_NE(kNormal, state_); | 204 DCHECK_NE(kNormal, state_); |
| 209 } | 205 } |
| OLD | NEW |