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

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

Issue 7193001: Move rtc_video_decoder* from media/filter/ to content/renderer/media/. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 6 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
Index: content/renderer/media/rtc_video_decoder.cc
===================================================================
--- content/renderer/media/rtc_video_decoder.cc (revision 89290)
+++ content/renderer/media/rtc_video_decoder.cc (working copy)
@@ -2,12 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "media/filters/rtc_video_decoder.h"
+#include "content/renderer/media/rtc_video_decoder.h"
#include <deque>
#include "base/task.h"
-#include "googleurl/src/gurl.h"
#include "media/base/callback.h"
#include "media/base/filter_host.h"
#include "media/base/filters.h"
@@ -15,10 +14,17 @@
#include "media/base/media_format.h"
#include "media/base/video_frame.h"
-namespace media {
+using media::DemuxerStream;
+using media::FilterCallback;
+using media::FilterStatusCB;
+using media::kNoTimestamp;
+using media::Limits;
+using media::MediaFormat;
+using media::PIPELINE_OK;
+using media::StatisticsCallback;
+using media::VideoDecoder;
+using media::VideoFrame;
-static const char kMediaScheme[] = "media";
-
RTCVideoDecoder::RTCVideoDecoder(MessageLoop* message_loop,
const std::string& url)
: message_loop_(message_loop),
@@ -54,7 +60,7 @@
media_format_.SetAsInteger(MediaFormat::kSurfaceType,
static_cast<int>(VideoFrame::YV12));
media_format_.SetAsInteger(MediaFormat::kSurfaceFormat,
- static_cast<int>(VideoFrame::TYPE_SYSTEM_MEMORY));
+ static_cast<int>(VideoFrame::TYPE_SYSTEM_MEMORY));
state_ = kNormal;
@@ -113,7 +119,8 @@
// TODO(ronghuawu): Stop rtc
}
-void RTCVideoDecoder::Seek(base::TimeDelta time, const FilterStatusCB& cb) {
+void RTCVideoDecoder::Seek(base::TimeDelta time,
+ const FilterStatusCB& cb) {
if (MessageLoop::current() != message_loop_) {
message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &RTCVideoDecoder::Seek,
@@ -190,30 +197,28 @@
return true;
}
-int RTCVideoDecoder::FrameSizeChange(unsigned int width,
- unsigned int height,
- unsigned int number_of_streams) {
+bool RTCVideoDecoder::SetSize(int width, int height, int reserved) {
width_ = width;
height_ = height;
media_format_.SetAsInteger(MediaFormat::kWidth, width_);
media_format_.SetAsInteger(MediaFormat::kHeight, height_);
host()->SetVideoSize(width_, height_);
- return 0;
+ return true;
}
-int RTCVideoDecoder::DeliverFrame(unsigned char* buffer,
- int buffer_size) {
- DCHECK(buffer);
+bool RTCVideoDecoder::RenderFrame(const cricket::VideoFrame* frame) {
+ DCHECK(frame);
- if (frame_queue_available_.size() == 0)
- return 0;
-
if (state_ != kNormal)
- return 0;
+ return true;
// This is called from another thread
lock_.Acquire();
+ if (frame_queue_available_.size() == 0) {
+ lock_.Release();
+ return true;
+ }
scoped_refptr<VideoFrame> video_frame = frame_queue_available_.front();
frame_queue_available_.pop_front();
lock_.Release();
@@ -228,32 +233,33 @@
kNoTimestamp,
kNoTimestamp,
&video_frame);
- if (!video_frame.get()) {
- return -1;
- }
+ if (!video_frame.get())
+ return false;
}
video_frame->SetTimestamp(host()->GetTime());
video_frame->SetDuration(base::TimeDelta::FromMilliseconds(30));
uint8* y_plane = video_frame->data(VideoFrame::kYPlane);
+ const uint8* y_plane_src = frame->GetYPlane();
for (size_t row = 0; row < video_frame->height(); ++row) {
- memcpy(y_plane, buffer, width_);
+ memcpy(y_plane, y_plane_src, frame->GetYPitch());
y_plane += video_frame->stride(VideoFrame::kYPlane);
- buffer += width_;
+ y_plane_src += frame->GetYPitch();
}
- size_t uv_width = width_/2;
uint8* u_plane = video_frame->data(VideoFrame::kUPlane);
+ const uint8* u_plane_src = frame->GetUPlane();
for (size_t row = 0; row < video_frame->height(); row += 2) {
- memcpy(u_plane, buffer, uv_width);
+ memcpy(u_plane, u_plane_src, frame->GetUPitch());
u_plane += video_frame->stride(VideoFrame::kUPlane);
- buffer += uv_width;
+ u_plane_src += frame->GetUPitch();
}
uint8* v_plane = video_frame->data(VideoFrame::kVPlane);
+ const uint8* v_plane_src = frame->GetVPlane();
for (size_t row = 0; row < video_frame->height(); row += 2) {
- memcpy(v_plane, buffer, uv_width);
+ memcpy(v_plane, v_plane_src, frame->GetVPitch());
v_plane += video_frame->stride(VideoFrame::kVPlane);
- buffer += uv_width;
+ v_plane_src += frame->GetVPitch();
}
if (MessageLoop::current() != message_loop_) {
@@ -266,12 +272,5 @@
VideoFrameReady(video_frame);
}
- return 0;
+ return true;
}
-
-bool RTCVideoDecoder::IsUrlSupported(const std::string& url) {
- GURL gurl(url);
- return gurl.SchemeIs(kMediaScheme);
-}
-
-} // namespace media

Powered by Google App Engine
This is Rietveld 408576698