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

Side by Side Diff: content/public/renderer/media_stream_video_sink.h

Issue 1849003002: Add video frame refresh to MediaStream and VideoCapture stacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed last round of comments from xjz and emircan. Created 4 years, 8 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 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_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ 5 #ifndef CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_
6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ 6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/common/media/video_capture.h" 13 #include "content/common/media/video_capture.h"
14 #include "content/public/renderer/media_stream_sink.h" 14 #include "content/public/renderer/media_stream_sink.h"
15 #include "media/base/video_capturer_source.h" 15 #include "media/base/video_capturer_source.h"
16 16 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
17 namespace blink {
18 class WebMediaStreamTrack;
19 }
20 17
21 namespace content { 18 namespace content {
22 19
20 class MediaStreamVideoTrack;
21
23 // MediaStreamVideoSink is an interface used for receiving video frames from a 22 // MediaStreamVideoSink is an interface used for receiving video frames from a
24 // Video Stream Track or a Video Source. 23 // Video Stream Track or a Video Source.
25 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html 24 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
26 // All methods calls will be done from the main render thread. 25 // All methods calls will be done from the main render thread.
ncarter (slow) 2016/04/06 17:18:26 Can you add a comment here saying that this class
miu 2016/04/07 20:07:43 Done.
27 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink { 26 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink {
28 public: 27 protected:
29 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when 28 MediaStreamVideoSink();
29 ~MediaStreamVideoSink() override;
30
31 // An implementation of MediaStreamVideoSink should call ConnectToTrack when
30 // it is ready to receive data from a video track. Before the implementation 32 // it is ready to receive data from a video track. Before the implementation
31 // is destroyed, RemoveFromVideoTrack must be called. 33 // is destroyed, DisconnectFromTrack must be called. This MediaStreamVideoSink
34 // base class holds a reference to the WebMediaStreamTrack until
35 // DisconnectFromTrack is called.
32 // 36 //
33 // Calls to these methods must be done on the main render thread. 37 // Calls to these methods must be done on the main render thread.
34 // Note that |callback| for frame delivery happens on the IO thread. 38 // Note that |callback| for frame delivery happens on the IO thread.
35 // 39 //
36 // Calling RemoveFromVideoTrack also not stop frame delivery through the 40 // Warning: Calling DisconnectFromTrack does not immediately stop frame
37 // callback immediately because it may happen on another thread. 41 // delivery through the |callback|, since frames are being delivered on a
38 // The added callback will be reset on the render thread. 42 // different thread.
39 static void AddToVideoTrack(MediaStreamVideoSink* sink, 43 void ConnectToTrack(const blink::WebMediaStreamTrack& track,
40 const VideoCaptureDeliverFrameCB& callback, 44 const VideoCaptureDeliverFrameCB& callback);
41 const blink::WebMediaStreamTrack& track); 45 void DisconnectFromTrack();
ncarter (slow) 2016/04/06 17:18:26 Though I understand what you're trying to do here,
miu 2016/04/07 20:07:43 Ah, yes. I reviewed the sites page, and I realize
42 static void RemoveFromVideoTrack(MediaStreamVideoSink* sink,
43 const blink::WebMediaStreamTrack& track);
44 46
45 protected: 47 // Returns true after ConnectToTrack() is called, and false after
46 ~MediaStreamVideoSink() override {} 48 // DisconnectFromTrack().
49 bool is_connected() const { return !!connected_track_; }
ncarter (slow) 2016/04/06 17:18:26 Could we expose this as connected_track(), returni
miu 2016/04/07 20:07:43 Done.
50
51 // Requests the source send a frame "soon" (e.g., to resolve picture loss or
52 // quality issues).
53 void RequestRefreshFrame();
ncarter (slow) 2016/04/06 17:18:26 This is an operation on the track/source, not on t
miu 2016/04/07 20:07:43 Done. Went with the 3rd option.
54
55 private:
56 // Set by ConnectToTrack() and cleared by DisconnectFromTrack(). The object
57 // is not owned by MediaStreamVideoSink, but is guaranteed to remain valid
58 // until the disconnect because MediaStreamVideoTrack disallows its own
59 // destruction while sinks are still connected.
60 MediaStreamVideoTrack* connected_track_;
ncarter (slow) 2016/04/06 17:18:26 Could this be a WebMediaStreamTrack? It is preferr
miu 2016/04/07 20:07:43 Done.
47 }; 61 };
48 62
49 63
50 } // namespace content 64 } // namespace content
51 65
52 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ 66 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698