| 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" | |
| 14 #include "content/public/renderer/media_stream_video_sink.h" | 13 #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 | |
| 26 class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase, | 24 class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase, |
| 27 public MediaStreamVideoSink { | 25 public MediaStreamVideoSink, |
| 26 public MediaStreamVideoSource { |
| 28 public: | 27 public: |
| 29 // Input mode constructor. | 28 // Input mode constructor. |
| 30 // In input mode, this class passes video frames from |track| to the | 29 // In input mode, this class passes video frames from |track| to the |
| 31 // associated pepper plugin. | 30 // associated pepper plugin. |
| 32 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, | 31 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, |
| 33 PP_Instance instance, | 32 PP_Instance instance, |
| 34 PP_Resource resource, | 33 PP_Resource resource, |
| 35 const blink::WebMediaStreamTrack& track); | 34 const blink::WebMediaStreamTrack& track); |
| 36 | 35 |
| 37 // Output mode constructor. | 36 // Output mode constructor. |
| 38 // In output mode, this class passes video frames from the associated | 37 // In output mode, this class passes video frames from the associated |
| 39 // pepper plugin to a newly created blink::WebMediaStreamTrack. | 38 // pepper plugin to a newly created blink::WebMediaStreamTrack. |
| 40 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, | 39 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host, |
| 41 PP_Instance instance, | 40 PP_Instance instance, |
| 42 PP_Resource resource); | 41 PP_Resource resource); |
| 43 | 42 |
| 44 ~PepperMediaStreamVideoTrackHost() override; | 43 ~PepperMediaStreamVideoTrackHost() override; |
| 45 | 44 |
| 46 bool IsMediaStreamVideoTrackHost() override; | 45 bool IsMediaStreamVideoTrackHost() override; |
| 47 | 46 |
| 48 blink::WebMediaStreamTrack track() { return track_; } | 47 blink::WebMediaStreamTrack track() { return track_; } |
| 49 | 48 |
| 50 private: | 49 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 | |
| 56 void InitBuffers(); | 50 void InitBuffers(); |
| 57 | 51 |
| 58 // PepperMediaStreamTrackHostBase overrides: | 52 // PepperMediaStreamTrackHostBase overrides: |
| 59 void OnClose() override; | 53 void OnClose() override; |
| 60 int32_t OnHostMsgEnqueueBuffer(ppapi::host::HostMessageContext* context, | 54 int32_t OnHostMsgEnqueueBuffer(ppapi::host::HostMessageContext* context, |
| 61 int32_t index) override; | 55 int32_t index) override; |
| 62 | 56 |
| 63 // Sends frame with |index| to |track_|. | 57 // Sends frame with |index| to |track_|. |
| 64 int32_t SendFrameToTrack(int32_t index); | 58 int32_t SendFrameToTrack(int32_t index); |
| 65 | 59 |
| 66 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame, | 60 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame, |
| 67 base::TimeTicks estimated_capture_time); | 61 base::TimeTicks estimated_capture_time); |
| 68 | 62 |
| 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 |
| 69 // ResourceHost overrides: | 77 // ResourceHost overrides: |
| 70 void DidConnectPendingHostToResource() override; | 78 void DidConnectPendingHostToResource() override; |
| 71 | 79 |
| 72 // ResourceMessageHandler overrides: | 80 // ResourceMessageHandler overrides: |
| 73 int32_t OnResourceMessageReceived( | 81 int32_t OnResourceMessageReceived( |
| 74 const IPC::Message& msg, | 82 const IPC::Message& msg, |
| 75 ppapi::host::HostMessageContext* context) override; | 83 ppapi::host::HostMessageContext* context) override; |
| 76 | 84 |
| 77 // Message handlers: | 85 // Message handlers: |
| 78 int32_t OnHostMsgConfigure( | 86 int32_t OnHostMsgConfigure( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 100 | 108 |
| 101 // Plugin specified frame format. | 109 // Plugin specified frame format. |
| 102 PP_VideoFrame_Format plugin_frame_format_; | 110 PP_VideoFrame_Format plugin_frame_format_; |
| 103 | 111 |
| 104 // The size of frame pixels in bytes. | 112 // The size of frame pixels in bytes. |
| 105 uint32_t frame_data_size_; | 113 uint32_t frame_data_size_; |
| 106 | 114 |
| 107 // TODO(ronghuawu): Remove |type_| and split PepperMediaStreamVideoTrackHost | 115 // TODO(ronghuawu): Remove |type_| and split PepperMediaStreamVideoTrackHost |
| 108 // into 2 classes for read and write. | 116 // into 2 classes for read and write. |
| 109 TrackType type_; | 117 TrackType type_; |
| 118 bool output_started_; |
| 110 | 119 |
| 111 // Internal class used for delivering video frames on the IO-thread to | 120 // Internal class used for delivering video frames on the IO-thread to |
| 112 // the MediaStreamVideoSource implementation. | 121 // the MediaStreamVideoSource implementation. |
| 113 class FrameDeliverer; | 122 class FrameDeliverer; |
| 114 scoped_refptr<FrameDeliverer> frame_deliverer_; | 123 scoped_refptr<FrameDeliverer> frame_deliverer_; |
| 115 | 124 |
| 116 base::WeakPtrFactory<PepperMediaStreamVideoTrackHost> weak_factory_; | 125 base::WeakPtrFactory<PepperMediaStreamVideoTrackHost> weak_factory_; |
| 117 | 126 |
| 118 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamVideoTrackHost); | 127 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamVideoTrackHost); |
| 119 }; | 128 }; |
| 120 | 129 |
| 121 } // namespace content | 130 } // namespace content |
| 122 | 131 |
| 123 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ | 132 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_ |
| OLD | NEW |