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

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

Issue 129923002: Implements MediaStreamVideoSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: per's comments and fix the build Created 6 years, 11 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/media_stream_video_source.cc
diff --git a/content/renderer/media/media_stream_video_source.cc b/content/renderer/media/media_stream_video_source.cc
index acdb7dfc9012677655a044d41e43688d08d1cde3..8a7f0ed9169bfb4e2091b03c32ed258ead590912 100644
--- a/content/renderer/media/media_stream_video_source.cc
+++ b/content/renderer/media/media_stream_video_source.cc
@@ -4,22 +4,39 @@
#include "content/renderer/media/media_stream_video_source.h"
-#include "base/logging.h"
-#include "content/public/renderer/media_stream_video_sink.h"
+#include "content/renderer/media/media_stream_dependency_factory.h"
+#include "media/base/video_frame.h"
+#include "third_party/libjingle/source/talk/app/webrtc/remotevideocapturer.h"
+#include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h"
namespace content {
+MediaStreamVideoSource::MediaStreamVideoSource(
+ MediaStreamDependencyFactory* factory)
+ : factory_(factory),
+ width_(0),
+ height_(0),
+ first_frame_timestamp_(media::kNoTimestamp()) {
+ DCHECK(factory_);
+}
+
void MediaStreamVideoSource::AddTrack(
const blink::WebMediaStreamTrack& track,
const blink::WebMediaConstraints& constraints) {
- // TODO(ronghuawu): Put |track| in the registered tracks list. Will later
- // deliver frames to it according to |constraints|.
+ factory_->CreateNativeMediaStreamTrack(track);
}
void MediaStreamVideoSource::RemoveTrack(
const blink::WebMediaStreamTrack& track) {
- // TODO(ronghuawu): Remove |track| from the list, i.e. will stop delivering
- // frame to |track|.
+ // TODO(ronghuawu): What should be done here? Do we really need RemoveTrack?
+}
+
+void MediaStreamVideoSource::Init() {
no longer working on chromium 2014/01/15 15:57:22 how this Init() should be used? can it be called m
Ronghua Wu (Left Chromium) 2014/01/15 18:38:58 Added comments in header file.
+ if (!adapter_) {
+ const webrtc::MediaConstraintsInterface* constraints = NULL;
+ adapter_ = factory_->CreateVideoSource(new webrtc::RemoteVideoCapturer(),
+ constraints);
+ }
}
void MediaStreamVideoSource::SetReadyState(
@@ -30,7 +47,38 @@ void MediaStreamVideoSource::SetReadyState(
void MediaStreamVideoSource::DeliverVideoFrame(
const scoped_refptr<media::VideoFrame>& frame) {
- // TODO(ronghuawu): Deliver |frame| to all the registered tracks.
+ if (first_frame_timestamp_ == media::kNoTimestamp()) {
+ first_frame_timestamp_ = frame->GetTimestamp();
+ }
+
+ cricket::VideoRenderer* input = adapter_->FrameInput();
+ if (width_ != frame->coded_size().width() ||
+ height_ != frame->coded_size().height()) {
+ width_ = frame->coded_size().width();
+ height_ = frame->coded_size().height();
+ const int reserved = 0;
+ input->SetSize(width_, height_, reserved);
+ }
+
+ cricket::WebRtcVideoFrame cricket_frame;
+ // TODO(ronghuawu): we assume contiguous layout of image planes and
no longer working on chromium 2014/01/15 15:57:22 Is this a comment or TODO?
Ronghua Wu (Left Chromium) 2014/01/15 18:38:58 Moved to header as a note.
+ // FOURCC_I420.
+ const int64 elapsed_time =
no longer working on chromium 2014/01/15 15:57:22 nit, s/elapsed_time/elapsed_time_ns/g the same for
Ronghua Wu (Left Chromium) 2014/01/15 18:38:58 Done.
+ (frame->GetTimestamp() - first_frame_timestamp_).InMicroseconds() *
+ base::Time::kNanosecondsPerMicrosecond;
+ const int64 time_stamp = frame->GetTimestamp().InMicroseconds() *
+ base::Time::kNanosecondsPerMicrosecond;
+ const size_t size =
+ media::VideoFrame::AllocationSize(frame->format(), frame->coded_size());
+ const size_t pixel_width = 1;
+ const size_t pixel_height = 1;
+ const int rotation = 0;
+ cricket_frame.Alias(frame->data(0), size,
+ width_, height_,
+ pixel_width, pixel_height,
+ elapsed_time, time_stamp,
+ rotation);
+ input->RenderFrame(&cricket_frame);
}
MediaStreamVideoSource::~MediaStreamVideoSource() {

Powered by Google App Engine
This is Rietveld 408576698