Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Unified Diff: content/renderer/media/rtc_video_decoder.cc

Issue 7932005: Reland r101418: Fix aspect ratio and clarify video frame dimensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/media/rtc_video_decoder.h ('k') | content/renderer/media/rtc_video_decoder_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/rtc_video_decoder.cc
diff --git a/content/renderer/media/rtc_video_decoder.cc b/content/renderer/media/rtc_video_decoder.cc
index dfc43a1bdf59e245626ec60b959de917ff2e879e..53f1fcec34ba02c65961b0b688d31a27dc373ca7 100644
--- a/content/renderer/media/rtc_video_decoder.cc
+++ b/content/renderer/media/rtc_video_decoder.cc
@@ -31,8 +31,7 @@ using media::VideoFrame;
RTCVideoDecoder::RTCVideoDecoder(MessageLoop* message_loop,
const std::string& url)
: message_loop_(message_loop),
- width_(176),
- height_(144),
+ visible_size_(176, 144),
url_(url),
state_(kUnInitialized) {
}
@@ -125,9 +124,10 @@ void RTCVideoDecoder::Seek(base::TimeDelta time, const FilterStatusCB& cb) {
state_ = kSeeking;
// Create output buffer pool and pass the frames to renderer
- // so that the renderer can complete the seeking
+ // so that the renderer can complete the seeking.
for (size_t i = 0; i < Limits::kMaxVideoFrames; ++i) {
- VideoFrameReady(VideoFrame::CreateBlackFrame(width_, height_));
+ VideoFrameReady(VideoFrame::CreateBlackFrame(
+ visible_size_.width(), visible_size_.height()));
}
state_ = kNormal;
@@ -149,19 +149,16 @@ void RTCVideoDecoder::ProduceVideoFrame(
frame_queue_available_.push_back(video_frame);
}
-int RTCVideoDecoder::width() {
- return width_;
-}
-
-int RTCVideoDecoder::height() {
- return height_;
+gfx::Size RTCVideoDecoder::natural_size() {
+ // TODO(vrk): Return natural size when aspect ratio support is implemented.
+ return visible_size_;
}
bool RTCVideoDecoder::SetSize(int width, int height, int reserved) {
- width_ = width;
- height_ = height;
+ visible_size_.SetSize(width, height);
- host()->SetVideoSize(width_, height_);
+ // TODO(vrk): Provide natural size when aspect ratio support is implemented.
+ host()->SetNaturalVideoSize(visible_size_);
return true;
}
@@ -171,7 +168,7 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) {
if (state_ != kNormal)
return true;
- // This is called from another thread
+ // This is called from another thread.
scoped_refptr<VideoFrame> video_frame;
{
base::AutoLock auto_lock(lock_);
@@ -182,16 +179,24 @@ bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) {
frame_queue_available_.pop_front();
}
- // Check if there's a size change
- if (video_frame->width() != width_ || video_frame->height() != height_) {
- // Allocate new buffer based on the new size
+ // Check if there's a size change.
+ // TODO(vrk): Remove casts when media::VideoFrame is updated with gfx::Sizes
+ // for width/height.
+ if (video_frame->width() != static_cast<size_t>(visible_size_.width()) ||
+ video_frame->height() != static_cast<size_t>(visible_size_.height())) {
+ // Allocate new buffer based on the new size.
video_frame = VideoFrame::CreateFrame(VideoFrame::YV12,
- width_,
- height_,
+ visible_size_.width(),
+ visible_size_.height(),
kNoTimestamp,
kNoTimestamp);
}
+ // Only YV12 frames are supported.
+ DCHECK(video_frame->format() == VideoFrame::YV12);
+ // Aspect ratio unsupported; DCHECK when there are non-square pixels.
+ DCHECK(frame->GetPixelWidth() == 1);
+ DCHECK(frame->GetPixelHeight() == 1);
video_frame->SetTimestamp(host()->GetTime());
video_frame->SetDuration(base::TimeDelta::FromMilliseconds(30));
« no previous file with comments | « content/renderer/media/rtc_video_decoder.h ('k') | content/renderer/media/rtc_video_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698