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

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 nick's PS3 comments (moving non-observer impl out of MSVideoSink interface). 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
23 // MediaStreamVideoSink is an interface used for receiving video frames from a 20 // MediaStreamVideoSink is an interface used for receiving video frames from a
24 // Video Stream Track or a Video Source. 21 // Video Stream Track or a Video Source. It should be extended by embedders,
22 // which connect/disconnect the sink implementation to a track to start/stop the
23 // flow of video frames.
24 //
25 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html 25 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
26 // All methods calls will be done from the main render thread. 26 // All methods calls will be done from the main render thread.
27 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink { 27 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink {
28 public: 28 protected:
29 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when 29 MediaStreamVideoSink();
30 ~MediaStreamVideoSink() override;
31
32 // An implementation of MediaStreamVideoSink should call ConnectToTrack when
30 // it is ready to receive data from a video track. Before the implementation 33 // it is ready to receive data from a video track. Before the implementation
31 // is destroyed, RemoveFromVideoTrack must be called. 34 // is destroyed, DisconnectFromTrack must be called. This MediaStreamVideoSink
35 // base class holds a reference to the WebMediaStreamTrack until
36 // DisconnectFromTrack is called.
32 // 37 //
33 // Calls to these methods must be done on the main render thread. 38 // Calls to these methods must be done on the main render thread.
34 // Note that |callback| for frame delivery happens on the IO thread. 39 // Note that |callback| for frame delivery happens on the IO thread.
35 // 40 //
36 // Calling RemoveFromVideoTrack also not stop frame delivery through the 41 // Warning: Calling DisconnectFromTrack does not immediately stop frame
37 // callback immediately because it may happen on another thread. 42 // delivery through the |callback|, since frames are being delivered on a
38 // The added callback will be reset on the render thread. 43 // different thread.
39 static void AddToVideoTrack(MediaStreamVideoSink* sink, 44 void ConnectToTrack(const blink::WebMediaStreamTrack& track,
40 const VideoCaptureDeliverFrameCB& callback, 45 const VideoCaptureDeliverFrameCB& callback);
41 const blink::WebMediaStreamTrack& track); 46 void DisconnectFromTrack();
42 static void RemoveFromVideoTrack(MediaStreamVideoSink* sink,
43 const blink::WebMediaStreamTrack& track);
44 47
45 protected: 48 // Returns the currently-connected track, or a null instance otherwise.
46 ~MediaStreamVideoSink() override {} 49 const blink::WebMediaStreamTrack& connected_track() const {
50 return connected_track_;
51 }
52
53 private:
54 // Set by ConnectToTrack() and cleared by DisconnectFromTrack().
55 blink::WebMediaStreamTrack connected_track_;
47 }; 56 };
48 57
49 58
50 } // namespace content 59 } // namespace content
51 60
52 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ 61 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_
OLDNEW
« no previous file with comments | « content/public/renderer/media_stream_utils.cc ('k') | content/public/renderer/media_stream_video_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698