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

Side by Side Diff: media/video/capture/video_capture.h

Issue 23587018: Replace media::VideoCapture::VideoFrameBuffer with media::VideoFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 4fe79a572 Initial. Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file contains abstract classes used for media filter to handle video 5 // This file contains abstract classes used for media filter to handle video
6 // capture devices. 6 // capture devices.
7 7
8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ 8 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ 9 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "media/base/media_export.h" 13 #include "media/base/media_export.h"
14 #include "media/base/video_frame.h"
15 #include "media/video/capture/video_capture_types.h" 14 #include "media/video/capture/video_capture_types.h"
16 15
17 namespace media { 16 namespace media {
18 17
18 class VideoFrame;
19
19 class MEDIA_EXPORT VideoCapture { 20 class MEDIA_EXPORT VideoCapture {
20 public: 21 public:
21 // TODO(wjia): consider merging with media::VideoFrame if possible.
22 class VideoFrameBuffer : public base::RefCountedThreadSafe<VideoFrameBuffer> {
23 public:
24 VideoFrameBuffer()
25 : width(0),
26 height(0),
27 stride(0),
28 buffer_size(0),
29 memory_pointer(NULL) {}
30
31 int width;
32 int height;
33 int stride;
34 size_t buffer_size;
35 uint8* memory_pointer;
36 base::Time timestamp;
37
38 private:
39 friend class base::RefCountedThreadSafe<VideoFrameBuffer>;
40 ~VideoFrameBuffer() {}
41
42 DISALLOW_COPY_AND_ASSIGN(VideoFrameBuffer);
43 };
44
45 // TODO(wjia): add error codes. 22 // TODO(wjia): add error codes.
46 // TODO(wjia): support weak ptr. 23 // TODO(wjia): support weak ptr.
47 // Callbacks provided by client for notification of events. 24 // Callbacks provided by client for notification of events.
48 class MEDIA_EXPORT EventHandler { 25 class MEDIA_EXPORT EventHandler {
49 public: 26 public:
50 // Notify client that video capture has been started. 27 // Notify client that video capture has been started.
51 virtual void OnStarted(VideoCapture* capture) = 0; 28 virtual void OnStarted(VideoCapture* capture) = 0;
52 29
53 // Notify client that video capture has been stopped. 30 // Notify client that video capture has been stopped.
54 virtual void OnStopped(VideoCapture* capture) = 0; 31 virtual void OnStopped(VideoCapture* capture) = 0;
55 32
56 // Notify client that video capture has been paused. 33 // Notify client that video capture has been paused.
57 virtual void OnPaused(VideoCapture* capture) = 0; 34 virtual void OnPaused(VideoCapture* capture) = 0;
58 35
59 // Notify client that video capture has hit some error |error_code|. 36 // Notify client that video capture has hit some error |error_code|.
60 virtual void OnError(VideoCapture* capture, int error_code) = 0; 37 virtual void OnError(VideoCapture* capture, int error_code) = 0;
61 38
62 // Notify client that the client has been removed and no more calls will be 39 // Notify client that the client has been removed and no more calls will be
63 // received. 40 // received.
64 virtual void OnRemoved(VideoCapture* capture) = 0; 41 virtual void OnRemoved(VideoCapture* capture) = 0;
65 42
66 // Notify client that a buffer is available. 43 // Notify client that a buffer is available.
67 virtual void OnBufferReady(VideoCapture* capture, 44 virtual void OnFrameReady(
68 scoped_refptr<VideoFrameBuffer> buffer) = 0; 45 VideoCapture* capture,
46 const scoped_refptr<media::VideoFrame>& frame) = 0;
69 47
70 // Notify client about device info. 48 // Notify client about device info.
71 virtual void OnDeviceInfoReceived( 49 virtual void OnDeviceInfoReceived(
72 VideoCapture* capture, 50 VideoCapture* capture,
73 const VideoCaptureParams& device_info) = 0; 51 const VideoCaptureParams& device_info) = 0;
74 52
75 // Notify client about the newly changed device info. 53 // Notify client about the newly changed device info.
76 virtual void OnDeviceInfoChanged( 54 virtual void OnDeviceInfoChanged(
77 VideoCapture* capture, 55 VideoCapture* capture,
78 const VideoCaptureParams& device_info) {}; 56 const VideoCaptureParams& device_info) {};
79 57
80 protected: 58 protected:
81 virtual ~EventHandler() {} 59 virtual ~EventHandler() {}
82 }; 60 };
83 61
84 VideoCapture() {} 62 VideoCapture() {}
85 63
86 // Request video capture to start capturing with |capability|. 64 // Request video capture to start capturing with |capability|.
87 // Also register |handler| with video capture for event handling. 65 // Also register |handler| with video capture for event handling.
88 // |handler| must remain valid until it has received |OnRemoved()|. 66 // |handler| must remain valid until it has received |OnRemoved()|.
89 virtual void StartCapture(EventHandler* handler, 67 virtual void StartCapture(EventHandler* handler,
90 const VideoCaptureCapability& capability) = 0; 68 const VideoCaptureCapability& capability) = 0;
91 69
92 // Request video capture to stop capturing for client |handler|. 70 // Request video capture to stop capturing for client |handler|.
93 // |handler| must remain valid until it has received |OnRemoved()|. 71 // |handler| must remain valid until it has received |OnRemoved()|.
94 virtual void StopCapture(EventHandler* handler) = 0; 72 virtual void StopCapture(EventHandler* handler) = 0;
95 73
96 // Feed buffer to video capture when done with it.
97 virtual void FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) = 0;
98
99 virtual bool CaptureStarted() = 0; 74 virtual bool CaptureStarted() = 0;
100 virtual int CaptureWidth() = 0; 75 virtual int CaptureWidth() = 0;
101 virtual int CaptureHeight() = 0; 76 virtual int CaptureHeight() = 0;
102 virtual int CaptureFrameRate() = 0; 77 virtual int CaptureFrameRate() = 0;
103 78
104 protected: 79 protected:
105 virtual ~VideoCapture() {} 80 virtual ~VideoCapture() {}
106 81
107 private: 82 private:
108 DISALLOW_COPY_AND_ASSIGN(VideoCapture); 83 DISALLOW_COPY_AND_ASSIGN(VideoCapture);
109 }; 84 };
110 85
111 } // namespace media 86 } // namespace media
112 87
113 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_ 88 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698