Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(340)

Side by Side Diff: content/renderer/media/video_source_handler.h

Issue 14312015: Effects Pepper Plugin and MediaStream Glue. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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_SOURCE_HANDLER_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_SOURCE_HANDLER_H_
7
8 #include <string>
9
10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/synchronization/lock.h"
14 #include "content/common/content_export.h"
15 #include "content/renderer/media/media_stream_registry_interface.h"
16 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h"
17 #include "third_party/libjingle/source/talk/media/base/videoframe.h"
18 #include "third_party/libjingle/source/talk/media/base/videorenderer.h"
19 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h"
20
21 namespace content {
22
23 class MediaStreamDependencyFactory;
24 class MediaStreamRegistryInterface;
25
26 // Interface used by the effects pepper plugin to get captured frame
27 // from the video track.
28 class CONTENT_EXPORT FrameReaderInterface {
29 public:
30 // Gets the last captured frame.
31 // The ownership of the |frame| transfers to the caller. So the caller must
32 // release |frame| when done with it.
33 virtual bool GetFrame(cricket::VideoFrame** frame) = 0;
34
35 protected:
36 virtual ~FrameReaderInterface() {}
37 };
38
39 // PpFrameReader implements cricket::VideoRenderer so that it can be attached
40 // to native video track's video source. It also implements
41 // FrameReaderInterface, which will be used by the effects pepper plugin to
42 // get the captured frame.
43 class CONTENT_EXPORT PpFrameReader
44 : public NON_EXPORTED_BASE(cricket::VideoRenderer),
45 public FrameReaderInterface {
46 public:
47 PpFrameReader();
48 virtual ~PpFrameReader();
49
50 // Implements VideoRenderer.
51 virtual bool SetSize(int width, int height, int reserved) OVERRIDE;
52 virtual bool RenderFrame(const cricket::VideoFrame* frame) OVERRIDE;
53
54 // Implements FrameReaderInterface.
55 virtual bool GetFrame(cricket::VideoFrame** frame) OVERRIDE;
56
57 private:
58 scoped_ptr<cricket::VideoFrame> last_frame_;
59 base::Lock lock_;
60 };
61
62 // VideoSourceHandler is a glue class between the webrtc MediaStream and
63 // the effects pepper plugin host.
64 class CONTENT_EXPORT VideoSourceHandler {
65 public:
66 VideoSourceHandler(MediaStreamDependencyFactory* factory,
67 MediaStreamRegistryInterface* registry);
68 // Connects to the first video track in the MediaStream specified by |url| and
69 // outputs a handler as |frame_reader| for receiving captured frames.
70 // Returns true on success and false on failure.
71 bool Open(const std::string& url, FrameReaderInterface** frame_reader);
72 // Closes |frame_reader|'s connection with the first video track in
73 // the MediaStream specified by |url|, i.e. stops receiving frames from the
74 // video track.
75 // Returns true on success and false on failure.
76 bool Close(const std::string& url, FrameReaderInterface* frame_reader);
77
78 private:
79 scoped_refptr<webrtc::VideoSourceInterface> GetFirstVideoSource(
80 const std::string& url);
81
82 MediaStreamDependencyFactory* factory_;
83 MediaStreamRegistryInterface* registry_;
84 };
85
86 } // namespace content
87
88 #endif // CONTENT_RENDERER_MEDIA_VIDEO_SOURCE_HANDLER_H_
89
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698