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

Side by Side Diff: content/renderer/media/media_stream_video_track.h

Issue 155853002: Chrome MediaStream VideoTrack implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a comment. Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_
7 7
8 #include <vector>
9
8 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
10 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
11 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
12 #include "content/public/renderer/media_stream_video_sink.h" 14 #include "content/public/renderer/media_stream_video_sink.h"
13 #include "content/renderer/media/media_stream_track.h" 15 #include "content/renderer/media/media_stream_track.h"
16 #include "content/renderer/media/media_stream_video_source.h"
14 17
15 namespace webrtc { 18 namespace webrtc {
16 class VideoTrackInterface; 19 class VideoTrackInterface;
17 } 20 }
18 21
19 namespace content { 22 namespace content {
20 23
21 class MediaStreamDependencyFactory; 24 class MediaStreamDependencyFactory;
22 class WebRtcVideoSinkAdapter; 25 class WebRtcVideoSinkAdapter;
23 26
24 // MediaStreamVideoTrack is a video specific representation of a 27 // MediaStreamVideoTrack is a video specific representation of a
25 // blink::WebMediaStreamTrack in content. It is owned by the blink object 28 // blink::WebMediaStreamTrack in content. It is owned by the blink object
26 // and can be retrieved from a blink object using 29 // and can be retrieved from a blink object using
27 // WebMediaStreamTrack::extraData() 30 // WebMediaStreamTrack::extraData() or MediaStreamVideoTrack::GetVideoTrack.
28 class CONTENT_EXPORT MediaStreamVideoTrack : public MediaStreamTrack { 31 class CONTENT_EXPORT MediaStreamVideoTrack : public MediaStreamTrack {
29 public: 32 public:
33 // Help method to create a blink::WebMediaStreamTrack and a
34 // MediaStreamVideoTrack instance. The MediaStreamVideoTrack object is owned
35 // by the blink object in its WebMediaStreamTrack::ExtraData member.
36 // |callback| is triggered if the track is added to the source
37 // successfully and will receive video frames that match |constraints|
38 // or if the source fail to provide video frames.
39 // If |enabled| is true, sinks added to the track will
40 // receive video frames when the source deliver frames to the track.
41 static blink::WebMediaStreamTrack CreateVideoTrack(
42 MediaStreamVideoSource* source,
43 const blink::WebMediaConstraints& constraints,
44 const MediaStreamVideoSource::ConstraintsCallback& callback,
45 bool enabled,
46 MediaStreamDependencyFactory* factory);
47
48 static MediaStreamVideoTrack* GetVideoTrack(
49 const blink::WebMediaStreamTrack& track);
50
30 // Constructor for local video tracks. 51 // Constructor for local video tracks.
31 explicit MediaStreamVideoTrack(MediaStreamDependencyFactory* factory); 52 MediaStreamVideoTrack(
32 // Constructor for remote video tracks. 53 MediaStreamVideoSource* source,
33 explicit MediaStreamVideoTrack(webrtc::VideoTrackInterface* track); 54 const blink::WebMediaConstraints& constraints,
55 const MediaStreamVideoSource::ConstraintsCallback& callback,
56 bool enabled,
57 MediaStreamDependencyFactory* factory);
34 virtual ~MediaStreamVideoTrack(); 58 virtual ~MediaStreamVideoTrack();
35 void AddSink(MediaStreamVideoSink* sink); 59 virtual void AddSink(MediaStreamVideoSink* sink);
36 void RemoveSink(MediaStreamVideoSink* sink); 60 virtual void RemoveSink(MediaStreamVideoSink* sink);
37 61
38 virtual webrtc::VideoTrackInterface* GetVideoAdapter() OVERRIDE; 62 virtual webrtc::VideoTrackInterface* GetVideoAdapter() OVERRIDE;
63 virtual void SetEnabled(bool enabled) OVERRIDE;
64
65 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame);
66 void OnReadyStateChanged(blink::WebMediaStreamSource::ReadyState state);
67
68 protected:
69 // Used to DCHECK that we are called on the correct thread.
70 base::ThreadChecker thread_checker_;
39 71
40 private: 72 private:
41 // Used to DCHECK that we are called on the correct thread. 73 bool enabled_;
42 base::ThreadChecker thread_checker_; 74 std::vector<MediaStreamVideoSink*> sinks_;
43 ScopedVector<WebRtcVideoSinkAdapter> sinks_; 75
76 // Weak ref to the source this tracks is connected to. |source_| is owned
77 // by the blink::WebMediaStreamSource and is guaranteed to outlive the
78 // track.
79 MediaStreamVideoSource* source_;
44 80
45 // Weak ref to a MediaStreamDependencyFactory, owned by the RenderThread. 81 // Weak ref to a MediaStreamDependencyFactory, owned by the RenderThread.
46 // It's valid for the lifetime of RenderThread. 82 // It's valid for the lifetime of RenderThread.
47 MediaStreamDependencyFactory* factory_; 83 MediaStreamDependencyFactory* factory_;
48 84
49 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrack); 85 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrack);
50 }; 86 };
51 87
88 // WebRtcMediaStreamVideoTrack is a Chrome representation of a video track.
Ronghua Wu (Left Chromium) 2014/03/04 01:04:11 MediaStreamVideoTrack is 'a representation in cont
perkj_chrome 2014/03/04 10:44:51 ok- sticking to content.
Ronghua Wu (Left Chromium) 2014/03/04 23:50:55 I was more of hoping you can explain what is the d
89 // received on a PeerConnection.
90 // TODO(perkj): Replace WebRtcMediaStreamVideoTrack with a remote
91 // MediaStreamVideoSource class so that all tracks are MediaStreamVideoTracks
92 // and new tracks can be cloned from the original remote video track.
93 class CONTENT_EXPORT WebRtcMediaStreamVideoTrack
94 : public MediaStreamVideoTrack {
95 public:
96 explicit WebRtcMediaStreamVideoTrack(webrtc::VideoTrackInterface* track);
97 virtual ~WebRtcMediaStreamVideoTrack();
98 virtual void AddSink(MediaStreamVideoSink* sink) OVERRIDE;
99 virtual void RemoveSink(MediaStreamVideoSink* sink) OVERRIDE;
100
101 private:
102 ScopedVector<WebRtcVideoSinkAdapter> sinks_;
103
104 DISALLOW_COPY_AND_ASSIGN(WebRtcMediaStreamVideoTrack);
105 };
106
52 } // namespace content 107 } // namespace content
53 108
54 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ 109 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698