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

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

Issue 6902166: Add VideoCaptureImpl (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: change from review Created 9 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) 2011 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 // VideoCaptureImpl represents a capture device in renderer process. It provides
6 // interfaces for clients to Start/Stop capture. It also communicates to clients
7 // when buffer is ready, state of capture device is changed.
8
9 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
10 #define CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
11
12 #include <list>
13 #include <map>
14
15 #include "content/renderer/video_capture_message_filter.h"
16 #include "media/base/callback.h"
17 #include "media/video/capture/video_capture.h"
18 #include "ui/gfx/surface/transport_dib.h"
19
20 namespace base {
21 class MessageLoopProxy;
22 }
23
24 class VideoCaptureImpl
25 : public media::VideoCapture,
26 public VideoCaptureMessageFilter::Delegate {
27 public:
28 // media::VideoCapture interface.
29 virtual void StartCapture(media::VideoCapture::EventHandler* handler,
30 const VideoCaptureCapability& capability);
31 virtual void StopCapture(media::VideoCapture::EventHandler* handler);
32 virtual bool CaptureStarted();
33 virtual int CaptureWidth();
34 virtual int CaptureHeight();
35 virtual int CaptureFrameRate();
36
37 // VideoCaptureMessageFilter::Delegate interface.
38 virtual void OnBufferReceived(TransportDIB::Handle handle,
39 base::Time timestamp);
40 virtual void OnStateChanged(const media::VideoCapture::State& state);
41 virtual void OnDeviceInfoReceived(
42 const media::VideoCaptureParams& device_info);
43
44 bool pending_start() {
45 return (new_width_ > 0 && new_height_ > 0);
46 }
47
48 private:
49 friend class VideoCaptureImplManager;
50 friend class VideoCaptureImplTest;
51
52 enum State {
53 kStarted,
54 kStopping,
55 kStopped
56 };
57
58 struct DIBBuffer {
59 public:
60 DIBBuffer(TransportDIB* d, media::VideoCapture::VideoFrameBuffer* ptr);
61 ~DIBBuffer();
62
63 TransportDIB* dib;
64 scoped_refptr<media::VideoCapture::VideoFrameBuffer> mapped_memory;
65 };
66
67 VideoCaptureImpl(media::VideoCaptureSessionId id,
68 scoped_refptr<base::MessageLoopProxy> ml_proxy,
69 VideoCaptureMessageFilter* filter);
70 virtual ~VideoCaptureImpl();
71
72 void Init();
73 void DeInit(Task* task);
74 void StopDevice();
75 void RestartCapture();
76 void StartCaptureInternal();
77 void AddDelegateOnIOThread();
78 void RemoveDelegateOnIOThread(Task* task);
79
80 scoped_refptr<VideoCaptureMessageFilter> message_filter_;
81 media::VideoCaptureSessionId session_id_;
82 scoped_refptr<base::MessageLoopProxy> ml_proxy_;
83 int device_id_;
84
85 // Pool of DIBs.
86 typedef std::list<DIBBuffer*> CachedDIB;
87 CachedDIB cached_dibs_;
88
89 typedef std::map<media::VideoCapture::EventHandler*, VideoCaptureCapability>
90 ClientInfo;
91 ClientInfo clients_;
92 std::list<media::VideoCapture::EventHandler*> master_clients_;
93
94 typedef std::map<media::VideoCapture::EventHandler*, int> PendingClient;
95 PendingClient pending_clients_;
96
97 int width_;
98 int height_;
99 int frame_rate_;
100 media::VideoFrame::Format video_type_;
101
102 int new_width_;
103 int new_height_;
104 State state_;
105
106 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImpl);
107 };
108
109 DISABLE_RUNNABLE_METHOD_REFCOUNT(VideoCaptureImpl);
110
111 #endif // CONTENT_RENDERER_MEDIA_VIDEO_CAPTURE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698