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

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: 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.
25 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html 22 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
26 // All methods calls will be done from the main render thread. 23 // All methods calls will be done from the main render thread.
27 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink { 24 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink {
28 public: 25 protected:
29 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when 26 MediaStreamVideoSink();
27 ~MediaStreamVideoSink() override;
28
29 // An implementation of MediaStreamVideoSink should call ConnectToTrack when
30 // it is ready to receive data from a video track. Before the implementation 30 // it is ready to receive data from a video track. Before the implementation
31 // is destroyed, RemoveFromVideoTrack must be called. 31 // is destroyed, DisconnectFromTrack must be called. This MediaStreamVideoSink
32 // base class holds a reference to the WebMediaStreamTrack until
33 // DisconnectFromTrack is called.
32 // 34 //
33 // Calls to these methods must be done on the main render thread. 35 // Calls to these methods must be done on the main render thread.
34 // Note that |callback| for frame delivery happens on the IO thread. 36 // Note that |callback| for frame delivery happens on the IO thread.
35 // 37 //
36 // Calling RemoveFromVideoTrack also not stop frame delivery through the 38 // Warning: Calling DisconnectFromTrack does not immediately stop frame
37 // callback immediately because it may happen on another thread. 39 // delivery through the |callback|, since frames are being delivered on a
38 // The added callback will be reset on the render thread. 40 // different thread.
39 static void AddToVideoTrack(MediaStreamVideoSink* sink, 41 void ConnectToTrack(const blink::WebMediaStreamTrack& track,
40 const VideoCaptureDeliverFrameCB& callback, 42 const VideoCaptureDeliverFrameCB& callback);
41 const blink::WebMediaStreamTrack& track); 43 void DisconnectFromTrack();
42 static void RemoveFromVideoTrack(MediaStreamVideoSink* sink,
43 const blink::WebMediaStreamTrack& track);
44 44
45 protected: 45 // Returns true after ConnectToTrack() is called, and false after
46 ~MediaStreamVideoSink() override {} 46 // DisconnectFromTrack().
47 bool is_connected() const { return !connected_track_.isNull(); }
48
49 // Requests the source a send a frame "soon" (e.g., to resolve picture loss or
xjz 2016/04/01 19:10:04 s/a send/send
miu 2016/04/01 23:24:27 Done.
50 // quality issues).
51 void RequestRefreshFrame();
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

Powered by Google App Engine
This is Rietveld 408576698