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

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

Issue 883293005: Cast: Basic cast_receiver API for chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed extra BUILD.gn line Created 5 years, 10 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 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop_proxy.h" 11 #include "base/message_loop/message_loop_proxy.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "content/common/media/video_capture.h" 13 #include "content/common/media/video_capture.h"
14 #include "content/renderer/media/media_stream_video_source.h" 14 #include "content/renderer/media/media_stream_video_source.h"
15 #include "media/base/video_capturer_source.h"
15 16
16 namespace content { 17 namespace content {
17 18
18 // VideoCapturerDelegate is a delegate used by MediaStreamVideoCapturerSource 19 // VideoCapturerDelegate is a delegate used by MediaStreamVideoCapturerSource
19 // for local video capturer. It uses VideoCaptureImplManager to start / stop 20 // for local video capturer. It uses VideoCaptureImplManager to start / stop
20 // and receive I420 frames from Chrome's video capture implementation. 21 // and receive I420 frames from Chrome's video capture implementation.
21 // 22 //
22 // This is a render thread only object. 23 // This is a render thread only object.
23 class CONTENT_EXPORT VideoCapturerDelegate { 24
25 class CONTENT_EXPORT VideoCapturerDelegate : public media::VideoCapturerSource {
24 public: 26 public:
25 typedef base::Callback<void(MediaStreamRequestResult result)> RunningCallback; 27 explicit VideoCapturerDelegate(const StreamDeviceInfo& device_info);
28 ~VideoCapturerDelegate() override;
26 29
27 explicit VideoCapturerDelegate(const StreamDeviceInfo& device_info); 30 // VideoCaptureDelegate Implementation.
28 virtual ~VideoCapturerDelegate(); 31 void GetCurrentSupportedFormats(
29
30 // Collects the formats that can currently be used.
31 // |max_requested_height|, |max_requested_width|, and
32 // |max_requested_frame_rate| is used by Tab and Screen capture to decide what
33 // resolution/framerate to generate. |callback| is triggered when the formats
34 // have been collected.
35 virtual void GetCurrentSupportedFormats(
36 int max_requested_width, 32 int max_requested_width,
37 int max_requested_height, 33 int max_requested_height,
38 double max_requested_frame_rate, 34 double max_requested_frame_rate,
39 const VideoCaptureDeviceFormatsCB& callback); 35 const VideoCaptureDeviceFormatsCB& callback) override;
40 36
41 // Starts capturing frames using the resolution in |params|. 37 void StartCapture(
42 // |new_frame_callback| is triggered when a new video frame is available.
43 // If capturing is started successfully then |running_callback| will be
44 // called with a parameter of true.
45 // If capturing fails to start or stopped due to an external event then
46 // |running_callback| will be called with a parameter of false.
47 virtual void StartCapture(
48 const media::VideoCaptureParams& params, 38 const media::VideoCaptureParams& params,
49 const VideoCaptureDeliverFrameCB& new_frame_callback, 39 const VideoCaptureDeliverFrameCB& new_frame_callback,
50 const RunningCallback& running_callback); 40 scoped_refptr<base::SingleThreadTaskRunner> frame_callback_task_runner,
41 const RunningCallback& running_callback) override;
51 42
52 // Stops capturing frames and clears all callbacks including the 43 void StopCapture() override;
53 // SupportedFormatsCallback callback.
54 virtual void StopCapture();
55 44
56 private: 45 private:
57 FRIEND_TEST_ALL_PREFIXES(MediaStreamVideoCapturerSourceTest, Ended); 46 FRIEND_TEST_ALL_PREFIXES(MediaStreamVideoCapturerSourceTest, Ended);
58 friend class base::RefCountedThreadSafe<VideoCapturerDelegate>;
59 friend class MockVideoCapturerDelegate; 47 friend class MockVideoCapturerDelegate;
60 48
61 void OnStateUpdateOnRenderThread(VideoCaptureState state); 49 void OnStateUpdateOnRenderThread(VideoCaptureState state);
62 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats); 50 void OnDeviceFormatsInUseReceived(const media::VideoCaptureFormats& formats);
63 void OnDeviceSupportedFormatsEnumerated( 51 void OnDeviceSupportedFormatsEnumerated(
64 const media::VideoCaptureFormats& formats); 52 const media::VideoCaptureFormats& formats);
65 53
66 // The id identifies which video capture device is used for this video 54 // The id identifies which video capture device is used for this video
67 // capture session. 55 // capture session.
68 media::VideoCaptureSessionId session_id_; 56 media::VideoCaptureSessionId session_id_;
(...skipping 17 matching lines...) Expand all
86 }; 74 };
87 75
88 // Owned by WebMediaStreamSource in Blink as a representation of a video 76 // Owned by WebMediaStreamSource in Blink as a representation of a video
89 // stream coming from a camera. 77 // stream coming from a camera.
90 // This is a render thread only object. All methods must be called on the 78 // This is a render thread only object. All methods must be called on the
91 // render thread. 79 // render thread.
92 class CONTENT_EXPORT MediaStreamVideoCapturerSource 80 class CONTENT_EXPORT MediaStreamVideoCapturerSource
93 : public MediaStreamVideoSource { 81 : public MediaStreamVideoSource {
94 public: 82 public:
95 MediaStreamVideoCapturerSource( 83 MediaStreamVideoCapturerSource(
96 const StreamDeviceInfo& device_info,
97 const SourceStoppedCallback& stop_callback, 84 const SourceStoppedCallback& stop_callback,
98 scoped_ptr<VideoCapturerDelegate> delegate); 85 scoped_ptr<media::VideoCapturerSource> delegate);
99 86
100 virtual ~MediaStreamVideoCapturerSource(); 87 virtual ~MediaStreamVideoCapturerSource();
101 88
89 void SetDeviceInfo(const StreamDeviceInfo& device_info);
90
102 protected: 91 protected:
103 // Implements MediaStreamVideoSource. 92 // Implements MediaStreamVideoSource.
104 void GetCurrentSupportedFormats( 93 void GetCurrentSupportedFormats(
105 int max_requested_width, 94 int max_requested_width,
106 int max_requested_height, 95 int max_requested_height,
107 double max_requested_frame_rate, 96 double max_requested_frame_rate,
108 const VideoCaptureDeviceFormatsCB& callback) override; 97 const VideoCaptureDeviceFormatsCB& callback) override;
109 98
110 void StartSourceImpl( 99 void StartSourceImpl(
111 const media::VideoCaptureFormat& format, 100 const media::VideoCaptureFormat& format,
112 const VideoCaptureDeliverFrameCB& frame_callback) override; 101 const VideoCaptureDeliverFrameCB& frame_callback) override;
113 102
114 void StopSourceImpl() override; 103 void StopSourceImpl() override;
115 104
116 private: 105 private:
106 void OnStarted(bool result);
117 // The delegate that provides video frames. 107 // The delegate that provides video frames.
118 scoped_ptr<VideoCapturerDelegate> delegate_; 108 scoped_ptr<media::VideoCapturerSource> delegate_;
119 109
120 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource); 110 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoCapturerSource);
121 }; 111 };
122 112
123 } // namespace content 113 } // namespace content
124 114
125 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_ 115 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_CAPTURER_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698