OLD | NEW |
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_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/public/common/media_stream_request.h" |
13 #include "content/public/renderer/media_stream_video_sink.h" | 14 #include "content/public/renderer/media_stream_video_sink.h" |
14 #include "content/renderer/media/media_stream_video_source.h" | |
15 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" | 15 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h" |
16 #include "media/base/video_frame.h" | 16 #include "media/base/video_frame.h" |
17 #include "ppapi/c/ppb_video_frame.h" | 17 #include "ppapi/c/ppb_video_frame.h" |
18 #include "ppapi/shared_impl/media_stream_video_track_shared.h" | 18 #include "ppapi/shared_impl/media_stream_video_track_shared.h" |
19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
20 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 | 23 |
| 24 class MediaStreamSource; |
| 25 |
24 class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase, | 26 class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase, |
25 public MediaStreamVideoSink, | 27 public MediaStreamVideoSink { |
26 public MediaStreamVideoSource { | |
27 public: | 28 public: |
28 // Input mode constructor. | 29 // Input mode constructor. |
29 // In input mode, this class passes video frames from |track| to the | 30 // In input mode, this class passes video frames from |track| to the |
30 // associated pepper plugin. | 31 // associated pepper plugin. |
31 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, | 32 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, |
32 PP_Instance instance, | 33 PP_Instance instance, |
33 PP_Resource resource, | 34 PP_Resource resource, |
34 const blink::WebMediaStreamTrack& track); | 35 const blink::WebMediaStreamTrack& track); |
35 | 36 |
36 // Output mode constructor. | 37 // Output mode constructor. |
37 // In output mode, this class passes video frames from the associated | 38 // In output mode, this class passes video frames from the associated |
38 // pepper plugin to a newly created blink::WebMediaStreamTrack. | 39 // pepper plugin to a newly created blink::WebMediaStreamTrack. |
39 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, | 40 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, |
40 PP_Instance instance, | 41 PP_Instance instance, |
41 PP_Resource resource); | 42 PP_Resource resource); |
42 | 43 |
43 ~PepperMediaStreamVideoTrackHost() override; | 44 ~PepperMediaStreamVideoTrackHost() override; |
44 | 45 |
45 bool IsMediaStreamVideoTrackHost() override; | 46 bool IsMediaStreamVideoTrackHost() override; |
46 | 47 |
47 blink::WebMediaStreamTrack track() { return track_; } | 48 blink::WebMediaStreamTrack track() { return track_; } |
48 | 49 |
49 private: | 50 private: |
| 51 // Implements a MediaStreamVideoSource that drives this host (output mode |
| 52 // only). VideoSource holds a weak reference to the host, and sets/clears |
| 53 // |frame_deliverer_|. |
| 54 class VideoSource; |
| 55 |
50 void InitBuffers(); | 56 void InitBuffers(); |
51 | 57 |
52 // PepperMediaStreamTrackHostBase overrides: | 58 // PepperMediaStreamTrackHostBase overrides: |
53 void OnClose() override; | 59 void OnClose() override; |
54 int32_t OnHostMsgEnqueueBuffer(ppapi::host::HostMessageContext* context, | 60 int32_t OnHostMsgEnqueueBuffer(ppapi::host::HostMessageContext* context, |
55 int32_t index) override; | 61 int32_t index) override; |
56 | 62 |
57 // Sends frame with |index| to |track_|. | 63 // Sends frame with |index| to |track_|. |
58 int32_t SendFrameToTrack(int32_t index); | 64 int32_t SendFrameToTrack(int32_t index); |
59 | 65 |
60 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame, | 66 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame, |
61 base::TimeTicks estimated_capture_time); | 67 base::TimeTicks estimated_capture_time); |
62 | 68 |
63 // MediaStreamVideoSource overrides: | |
64 void GetCurrentSupportedFormats( | |
65 int max_requested_width, | |
66 int max_requested_height, | |
67 double max_requested_frame_rate, | |
68 const VideoCaptureDeviceFormatsCB& callback) override; | |
69 | |
70 void StartSourceImpl( | |
71 const media::VideoCaptureFormat& format, | |
72 const blink::WebMediaConstraints& constraints, | |
73 const VideoCaptureDeliverFrameCB& frame_callback) override; | |
74 | |
75 void StopSourceImpl() override; | |
76 | |
77 // ResourceHost overrides: | 69 // ResourceHost overrides: |
78 void DidConnectPendingHostToResource() override; | 70 void DidConnectPendingHostToResource() override; |
79 | 71 |
80 // ResourceMessageHandler overrides: | 72 // ResourceMessageHandler overrides: |
81 int32_t OnResourceMessageReceived( | 73 int32_t OnResourceMessageReceived( |
82 const IPC::Message& msg, | 74 const IPC::Message& msg, |
83 ppapi::host::HostMessageContext* context) override; | 75 ppapi::host::HostMessageContext* context) override; |
84 | 76 |
85 // Message handlers: | 77 // Message handlers: |
86 int32_t OnHostMsgConfigure( | 78 int32_t OnHostMsgConfigure( |
(...skipping 21 matching lines...) Expand all Loading... |
108 | 100 |
109 // Plugin specified frame format. | 101 // Plugin specified frame format. |
110 PP_VideoFrame_Format plugin_frame_format_; | 102 PP_VideoFrame_Format plugin_frame_format_; |
111 | 103 |
112 // The size of frame pixels in bytes. | 104 // The size of frame pixels in bytes. |
113 uint32_t frame_data_size_; | 105 uint32_t frame_data_size_; |
114 | 106 |
115 // TODO(ronghuawu): Remove |type_| and split PepperMediaStreamVideoTrackHost | 107 // TODO(ronghuawu): Remove |type_| and split PepperMediaStreamVideoTrackHost |
116 // into 2 classes for read and write. | 108 // into 2 classes for read and write. |
117 TrackType type_; | 109 TrackType type_; |
118 bool output_started_; | |
119 | 110 |
120 // Internal class used for delivering video frames on the IO-thread to | 111 // Internal class used for delivering video frames on the IO-thread to |
121 // the MediaStreamVideoSource implementation. | 112 // the MediaStreamVideoSource implementation. |
122 class FrameDeliverer; | 113 class FrameDeliverer; |
123 scoped_refptr<FrameDeliverer> frame_deliverer_; | 114 scoped_refptr<FrameDeliverer> frame_deliverer_; |
124 | 115 |
125 base::WeakPtrFactory<PepperMediaStreamVideoTrackHost> weak_factory_; | 116 base::WeakPtrFactory<PepperMediaStreamVideoTrackHost> weak_factory_; |
126 | 117 |
127 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamVideoTrackHost); | 118 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamVideoTrackHost); |
128 }; | 119 }; |
129 | 120 |
130 } // namespace content | 121 } // namespace content |
131 | 122 |
132 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ | 123 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ |
OLD | NEW |