cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / renderer / media / webrtc / video_destination_handler.h
blob54b13304cdcaf541726566f41e29db83929c792c
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.
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_
8 #include <string>
9 #include <vector>
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "content/common/content_export.h"
14 #include "content/renderer/media/media_stream_video_source.h"
15 #include "media/base/video_frame_pool.h"
17 namespace content {
19 class MediaStreamRegistryInterface;
20 class PPB_ImageData_Impl;
22 // VideoDestinationHandler is a glue class between the content MediaStream and
23 // the effects pepper plugin host.
24 class CONTENT_EXPORT VideoDestinationHandler {
25 public:
26 // FrameWriterCallback is used to forward frames from the pepper host.
27 // It must be invoked on the main render thread.
28 typedef base::Callback<
29 void(const scoped_refptr<PPB_ImageData_Impl>& frame,
30 int64 time_stamp_ns)> FrameWriterCallback;
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);
42 private:
43 DISALLOW_COPY_AND_ASSIGN(VideoDestinationHandler);
46 // PpFrameWriter implements MediaStreamVideoSource and can therefore provide
47 // video frames to MediaStreamVideoTracks.
48 class CONTENT_EXPORT PpFrameWriter
49 : NON_EXPORTED_BASE(public MediaStreamVideoSource) {
50 public:
51 PpFrameWriter();
52 virtual ~PpFrameWriter();
54 // Returns a callback that can be used for delivering frames to this
55 // MediaStreamSource implementation.
56 VideoDestinationHandler::FrameWriterCallback GetFrameWriterCallback();
58 protected:
59 // MediaStreamVideoSource implementation.
60 void GetCurrentSupportedFormats(
61 int max_requested_width,
62 int max_requested_height,
63 double max_requested_frame_rate,
64 const VideoCaptureDeviceFormatsCB& callback) override;
65 void StartSourceImpl(
66 const media::VideoCaptureFormat& format,
67 const VideoCaptureDeliverFrameCB& frame_callback) override;
68 void StopSourceImpl() override;
70 private:
71 class FrameWriterDelegate;
72 scoped_refptr<FrameWriterDelegate> delegate_;
74 DISALLOW_COPY_AND_ASSIGN(PpFrameWriter);
77 } // namespace content
79 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_VIDEO_DESTINATION_HANDLER_H_