OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_DESTINATION_HANDLER_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_VIDEO_DESTINATION_HANDLER_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "base/synchronization/lock.h" |
| 13 #include "content/common/content_export.h" |
| 14 #include "third_party/libjingle/source/talk/media/base/videocapturer.h" |
| 15 |
| 16 namespace webkit { |
| 17 namespace ppapi { |
| 18 class PPB_ImageData_Impl; |
| 19 } |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 class MediaStreamDependencyFactory; |
| 25 class MediaStreamRegistryInterface; |
| 26 |
| 27 // Interface used by the effects pepper plugin to output the processed frame |
| 28 // to the video track. |
| 29 class CONTENT_EXPORT FrameWriterInterface { |
| 30 public: |
| 31 // The ownership of the |image_data| deosn't transfer. So the implementation |
| 32 // of this interface should make a copy of the |image_data| before return. |
| 33 virtual void PutFrame(webkit::ppapi::PPB_ImageData_Impl* image_data, |
| 34 int64 time_stamp_ns) = 0; |
| 35 virtual ~FrameWriterInterface() {} |
| 36 }; |
| 37 |
| 38 // PpFrameWriter implements cricket::VideoCapturer so that it can be used in |
| 39 // the native video track's video source. It also implements |
| 40 // FrameWriterInterface, which will be used by the effects pepper plugin to |
| 41 // inject the processed frame. |
| 42 class CONTENT_EXPORT PpFrameWriter |
| 43 : public NON_EXPORTED_BASE(cricket::VideoCapturer), |
| 44 public FrameWriterInterface { |
| 45 public: |
| 46 PpFrameWriter(); |
| 47 virtual ~PpFrameWriter(); |
| 48 |
| 49 // cricket::VideoCapturer implementation. |
| 50 // These methods are accessed from a libJingle worker thread. |
| 51 virtual cricket::CaptureState Start( |
| 52 const cricket::VideoFormat& capture_format) OVERRIDE; |
| 53 virtual void Stop() OVERRIDE; |
| 54 virtual bool IsRunning() OVERRIDE; |
| 55 virtual bool GetPreferredFourccs(std::vector<uint32>* fourccs) OVERRIDE; |
| 56 virtual bool GetBestCaptureFormat(const cricket::VideoFormat& desired, |
| 57 cricket::VideoFormat* best_format) OVERRIDE; |
| 58 virtual bool IsScreencast() const OVERRIDE; |
| 59 |
| 60 // FrameWriterInterface implementation. |
| 61 // This method will be called by the Pepper host from render thread. |
| 62 virtual void PutFrame(webkit::ppapi::PPB_ImageData_Impl* image_data, |
| 63 int64 time_stamp_ns) OVERRIDE; |
| 64 |
| 65 private: |
| 66 bool started_; |
| 67 // |lock_| is used to protect |started_| which will be accessed from different |
| 68 // threads - libjingle worker thread and render thread. |
| 69 base::Lock lock_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(PpFrameWriter); |
| 72 }; |
| 73 |
| 74 // VideoDestinationHandler is a glue class between the webrtc MediaStream and |
| 75 // the effects pepper plugin host. |
| 76 class CONTENT_EXPORT VideoDestinationHandler { |
| 77 public: |
| 78 // Instantiates and adds a new video track to the MediaStream specified by |
| 79 // |url|. Returns a handler for delivering frames to the new video track as |
| 80 // |frame_writer|. |
| 81 // If |factory| is NULL the MediaStreamDependencyFactory owned by |
| 82 // RenderThreadImpl::current() will be used. |
| 83 // If |registry| is NULL the global WebKit::WebMediaStreamRegistry will be |
| 84 // used to look up the media stream. |
| 85 // The caller of the function takes the ownership of |frame_writer|. |
| 86 // Returns true on success and false on failure. |
| 87 static bool Open(MediaStreamDependencyFactory* factory, |
| 88 MediaStreamRegistryInterface* registry, |
| 89 const std::string& url, |
| 90 FrameWriterInterface** frame_writer); |
| 91 |
| 92 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(VideoDestinationHandler); |
| 94 }; |
| 95 |
| 96 } // namespace content |
| 97 |
| 98 #endif // CONTENT_RENDERER_MEDIA_VIDEO_DESTINATION_HANDLER_H_ |
| 99 |
OLD | NEW |