|
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, | |
wjia(left Chromium)
2013/05/03 21:42:55
const webkit::ppapi::PPB_ImageData_Impl& image_dat
Ronghua Wu (Left Chromium)
2013/05/03 22:40:02
I can't actually. Before using the PPB_ImageData_I
| |
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 base::Lock lock_; | |
wjia(left Chromium)
2013/05/03 21:42:55
Please add comment on which is protected by this |
Ronghua Wu (Left Chromium)
2013/05/03 22:40:02
Done.
| |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(PpFrameWriter); | |
70 }; | |
71 | |
72 // VideoDestinationHandler is a glue class between the webrtc MediaStream and | |
73 // the effects pepper plugin host. | |
74 class CONTENT_EXPORT VideoDestinationHandler { | |
75 public: | |
76 // Instantiates and adds a new video track to the MediaStream specified by | |
77 // |url|. Returns a handler for delivering frames to the new video track as | |
78 // |frame_writer|. | |
79 // The caller of the function takes the ownership of |frame_writer|. | |
80 // Returns true on success and false on failure. | |
wjia(left Chromium)
2013/05/03 21:42:55
Could you add some comments on what are |factory|
Ronghua Wu (Left Chromium)
2013/05/03 22:40:02
Added comments. And change the code a bit so that
| |
81 static bool Open(MediaStreamDependencyFactory* factory, | |
82 MediaStreamRegistryInterface* registry, | |
83 const std::string& url, | |
84 FrameWriterInterface** frame_writer); | |
wjia(left Chromium)
2013/05/03 21:42:55
Is it possible to use frame_writer==NULL as indica
Ronghua Wu (Left Chromium)
2013/05/03 22:40:02
I prefer to keep as it's to align with the other O
| |
85 | |
86 private: | |
87 DISALLOW_COPY_AND_ASSIGN(VideoDestinationHandler); | |
88 }; | |
89 | |
90 } // namespace content | |
91 | |
92 #endif // CONTENT_RENDERER_MEDIA_VIDEO_DESTINATION_HANDLER_H_ | |
93 | |
OLD | NEW |