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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/media_stream_video_source.h" 5 #include "content/renderer/media/media_stream_video_source.h"
6 6
7 #include "base/logging.h" 7 #include "content/renderer/media/media_stream_dependency_factory.h"
8 #include "content/public/renderer/media_stream_video_sink.h" 8 #include "media/base/video_frame.h"
9 #include "third_party/libjingle/source/talk/app/webrtc/remotevideocapturer.h"
10 #include "third_party/libjingle/source/talk/media/webrtc/webrtcvideoframe.h"
9 11
10 namespace content { 12 namespace content {
11 13
14 MediaStreamVideoSource::MediaStreamVideoSource(
15 MediaStreamDependencyFactory* factory)
16 : factory_(factory),
17 width_(0),
18 height_(0),
19 first_frame_timestamp_(media::kNoTimestamp()) {
20 DCHECK(factory_);
21 }
22
12 void MediaStreamVideoSource::AddTrack( 23 void MediaStreamVideoSource::AddTrack(
13 const blink::WebMediaStreamTrack& track, 24 const blink::WebMediaStreamTrack& track,
14 const blink::WebMediaConstraints& constraints) { 25 const blink::WebMediaConstraints& constraints) {
15 // TODO(ronghuawu): Put |track| in the registered tracks list. Will later 26 factory_->CreateNativeMediaStreamTrack(track);
16 // deliver frames to it according to |constraints|.
17 } 27 }
18 28
19 void MediaStreamVideoSource::RemoveTrack( 29 void MediaStreamVideoSource::RemoveTrack(
20 const blink::WebMediaStreamTrack& track) { 30 const blink::WebMediaStreamTrack& track) {
21 // TODO(ronghuawu): Remove |track| from the list, i.e. will stop delivering 31 // TODO(ronghuawu): What should be done here? Do we really need RemoveTrack?
22 // frame to |track|. 32 }
33
34 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.
35 if (!adapter_) {
36 const webrtc::MediaConstraintsInterface* constraints = NULL;
37 adapter_ = factory_->CreateVideoSource(new webrtc::RemoteVideoCapturer(),
38 constraints);
39 }
23 } 40 }
24 41
25 void MediaStreamVideoSource::SetReadyState( 42 void MediaStreamVideoSource::SetReadyState(
26 blink::WebMediaStreamSource::ReadyState state) { 43 blink::WebMediaStreamSource::ReadyState state) {
27 // TODO(ronghuawu): Sets WebMediaStreamSource's ready state and notifies the 44 // TODO(ronghuawu): Sets WebMediaStreamSource's ready state and notifies the
28 // ready state to all registered tracks. 45 // ready state to all registered tracks.
29 } 46 }
30 47
31 void MediaStreamVideoSource::DeliverVideoFrame( 48 void MediaStreamVideoSource::DeliverVideoFrame(
32 const scoped_refptr<media::VideoFrame>& frame) { 49 const scoped_refptr<media::VideoFrame>& frame) {
33 // TODO(ronghuawu): Deliver |frame| to all the registered tracks. 50 if (first_frame_timestamp_ == media::kNoTimestamp()) {
51 first_frame_timestamp_ = frame->GetTimestamp();
52 }
53
54 cricket::VideoRenderer* input = adapter_->FrameInput();
55 if (width_ != frame->coded_size().width() ||
56 height_ != frame->coded_size().height()) {
57 width_ = frame->coded_size().width();
58 height_ = frame->coded_size().height();
59 const int reserved = 0;
60 input->SetSize(width_, height_, reserved);
61 }
62
63 cricket::WebRtcVideoFrame cricket_frame;
64 // 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.
65 // FOURCC_I420.
66 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.
67 (frame->GetTimestamp() - first_frame_timestamp_).InMicroseconds() *
68 base::Time::kNanosecondsPerMicrosecond;
69 const int64 time_stamp = frame->GetTimestamp().InMicroseconds() *
70 base::Time::kNanosecondsPerMicrosecond;
71 const size_t size =
72 media::VideoFrame::AllocationSize(frame->format(), frame->coded_size());
73 const size_t pixel_width = 1;
74 const size_t pixel_height = 1;
75 const int rotation = 0;
76 cricket_frame.Alias(frame->data(0), size,
77 width_, height_,
78 pixel_width, pixel_height,
79 elapsed_time, time_stamp,
80 rotation);
81 input->RenderFrame(&cricket_frame);
34 } 82 }
35 83
36 MediaStreamVideoSource::~MediaStreamVideoSource() { 84 MediaStreamVideoSource::~MediaStreamVideoSource() {
37 } 85 }
38 86
39 } // namespace content 87 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698