Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.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_frame_pool.h" | 15 #include "media/base/video_frame_pool.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 class PeerConnectionDependencyFactory; | |
| 20 class MediaStreamRegistryInterface; | 19 class MediaStreamRegistryInterface; |
| 21 class PPB_ImageData_Impl; | 20 class PPB_ImageData_Impl; |
| 22 | 21 |
| 23 // Interface used by the effects pepper plugin to output the processed frame | 22 // VideoDestinationHandler is a glue class between the content MediaStream and |
| 24 // to the video track. | 23 // the effects pepper plugin host. |
| 25 class CONTENT_EXPORT FrameWriterInterface { | 24 class CONTENT_EXPORT VideoDestinationHandler { |
| 26 public: | 25 public: |
| 27 // The ownership of the |image_data| deosn't transfer. So the implementation | 26 // FrameWriterCallback is used to forward frames from the pepper host. |
| 28 // of this interface should make a copy of the |image_data| before return. | 27 // It must be invoked on the main render thread. |
| 29 virtual void PutFrame(PPB_ImageData_Impl* image_data, | 28 typedef base::Callback< |
| 30 int64 time_stamp_ns) = 0; | 29 void(const scoped_refptr<PPB_ImageData_Impl>& frame, |
| 31 virtual ~FrameWriterInterface() {} | 30 int64 time_stamp_ns)> FrameWriterCallback; |
| 31 | |
| 32 // Instantiates and adds a new video track to the MediaStream specified by | |
| 33 // |url|. Returns a handler for delivering frames to the new video track as | |
| 34 // |frame_writer|. | |
| 35 // If |registry| is NULL the global blink::WebMediaStreamRegistry will be | |
| 36 // used to look up the media stream. | |
| 37 // Returns true on success and false on failure. | |
| 38 static bool Open(MediaStreamRegistryInterface* registry, | |
| 39 const std::string& url, | |
| 40 FrameWriterCallback* frame_writer); | |
| 41 | |
| 42 private: | |
| 43 DISALLOW_COPY_AND_ASSIGN(VideoDestinationHandler); | |
| 32 }; | 44 }; |
| 33 | 45 |
| 34 // PpFrameWriter implements MediaStreamVideoSource and can therefore provide | 46 // PpFrameWriter implements MediaStreamVideoSource and can therefore provide |
| 35 // video frames to MediaStreamVideoTracks. It also implements | 47 // video frames to MediaStreamVideoTracks. It implements a method |Bind| to |
|
magjed_chromium
2014/10/07 14:07:01
unterminated comment
perkj_chrome
2014/10/07 15:39:04
Done.
| |
| 36 // FrameWriterInterface, which will be used by the effects pepper plugin to | 48 |
| 37 // inject the processed frame. | |
| 38 class CONTENT_EXPORT PpFrameWriter | 49 class CONTENT_EXPORT PpFrameWriter |
| 39 : NON_EXPORTED_BASE(public MediaStreamVideoSource), | 50 : NON_EXPORTED_BASE(public MediaStreamVideoSource) { |
| 40 public FrameWriterInterface, | |
| 41 NON_EXPORTED_BASE(public base::SupportsWeakPtr<PpFrameWriter>) { | |
| 42 public: | 51 public: |
| 43 PpFrameWriter(); | 52 PpFrameWriter(); |
| 44 virtual ~PpFrameWriter(); | 53 virtual ~PpFrameWriter(); |
| 45 | 54 |
| 46 // FrameWriterInterface implementation. | 55 // Binds the MediaStreamVideoSource with |FrameWriterCallback| which can be |
| 47 // This method will be called by the Pepper host from render thread. | 56 // used by the effects pepper plugin host to inject processed frames. |
| 48 virtual void PutFrame(PPB_ImageData_Impl* image_data, | 57 VideoDestinationHandler::FrameWriterCallback Bind(); |
|
magjed_chromium
2014/10/07 14:07:01
Maybe 'Bind' is a strange name for this function?
perkj_chrome
2014/10/07 15:39:04
Done.
| |
| 49 int64 time_stamp_ns) OVERRIDE; | 58 |
| 50 protected: | 59 protected: |
| 51 // MediaStreamVideoSource implementation. | 60 // MediaStreamVideoSource implementation. |
| 52 virtual void GetCurrentSupportedFormats( | 61 virtual void GetCurrentSupportedFormats( |
| 53 int max_requested_width, | 62 int max_requested_width, |
| 54 int max_requested_height, | 63 int max_requested_height, |
| 55 double max_requested_frame_rate, | 64 double max_requested_frame_rate, |
| 56 const VideoCaptureDeviceFormatsCB& callback) OVERRIDE; | 65 const VideoCaptureDeviceFormatsCB& callback) OVERRIDE; |
| 57 virtual void StartSourceImpl( | 66 virtual void StartSourceImpl( |
| 58 const media::VideoCaptureFormat& format, | 67 const media::VideoCaptureFormat& format, |
| 59 const VideoCaptureDeliverFrameCB& frame_callback) OVERRIDE; | 68 const VideoCaptureDeliverFrameCB& frame_callback) OVERRIDE; |
| 60 virtual void StopSourceImpl() OVERRIDE; | 69 virtual void StopSourceImpl() OVERRIDE; |
| 61 | 70 |
| 62 private: | 71 private: |
| 63 media::VideoFramePool frame_pool_; | |
| 64 | |
| 65 class FrameWriterDelegate; | 72 class FrameWriterDelegate; |
| 66 scoped_refptr<FrameWriterDelegate> delegate_; | 73 scoped_refptr<FrameWriterDelegate> delegate_; |
| 67 | 74 |
| 68 DISALLOW_COPY_AND_ASSIGN(PpFrameWriter); | 75 DISALLOW_COPY_AND_ASSIGN(PpFrameWriter); |
| 69 }; | 76 }; |
| 70 | 77 |
| 71 // VideoDestinationHandler is a glue class between the content MediaStream and | |
| 72 // the effects pepper plugin host. | |
| 73 class CONTENT_EXPORT VideoDestinationHandler { | |
| 74 public: | |
| 75 // Instantiates and adds a new video track to the MediaStream specified by | |
| 76 // |url|. Returns a handler for delivering frames to the new video track as | |
| 77 // |frame_writer|. | |
| 78 // If |registry| is NULL the global blink::WebMediaStreamRegistry will be | |
| 79 // used to look up the media stream. | |
| 80 // The caller of the function takes the ownership of |frame_writer|. | |
| 81 // Returns true on success and false on failure. | |
| 82 static bool Open(MediaStreamRegistryInterface* registry, | |
| 83 const std::string& url, | |
| 84 FrameWriterInterface** frame_writer); | |
| 85 | |
| 86 private: | |
| 87 DISALLOW_COPY_AND_ASSIGN(VideoDestinationHandler); | |
| 88 }; | |
| 89 | |
| 90 } // namespace content | 78 } // namespace content |
| 91 | 79 |
| 92 #endif // CONTENT_RENDERER_MEDIA_VIDEO_DESTINATION_HANDLER_H_ | 80 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_ |
| OLD | NEW |