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

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

Issue 235353002: Extract VideoCaptureDeviceFactory out of VideoCaptureDevice and use for File and FakeVCD. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: perkj@s comments Created 6 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef MEDIA_VIDEO_CAPTURE_FILE_VIDEO_CAPTURE_DEVICE_H_ 5 #ifndef MEDIA_VIDEO_CAPTURE_FILE_VIDEO_CAPTURE_DEVICE_H_
6 #define MEDIA_VIDEO_CAPTURE_FILE_VIDEO_CAPTURE_DEVICE_H_ 6 #define MEDIA_VIDEO_CAPTURE_FILE_VIDEO_CAPTURE_DEVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "media/video/capture/video_capture_device.h" 14 #include "media/video/capture/video_capture_device.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 // Implementation of a VideoCaptureDevice class that reads from a file. Used for 18 // Implementation of a VideoCaptureDevice class that reads from a file. Used for
19 // testing the video capture pipeline when no real hardware is available. The 19 // testing the video capture pipeline when no real hardware is available. The
20 // only supported file format is YUV4MPEG2 (a.k.a. Y4M), a minimal container 20 // only supported file format is YUV4MPEG2 (a.k.a. Y4M), a minimal container
21 // with a series of uncompressed video only frames, see the link 21 // with a series of uncompressed video only frames, see the link
22 // http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 for more information 22 // http://wiki.multimedia.cx/index.php?title=YUV4MPEG2 for more information
23 // on the file format. Several restrictions and notes apply, see the 23 // on the file format. Several restrictions and notes apply, see the
24 // implementation file. 24 // implementation file.
25 // Example videos can be found in http://media.xiph.org/video/derf. 25 // Example videos can be found in http://media.xiph.org/video/derf.
26 class MEDIA_EXPORT FileVideoCaptureDevice : public VideoCaptureDevice { 26 class MEDIA_EXPORT FileVideoCaptureDevice : public VideoCaptureDevice {
27 public: 27 public:
28 // VideoCaptureDevice implementation, static methods. Create() returns a 28 static int64 ParseFileAndExtractVideoFormat(
29 // pointer to the object, fully owned by the caller. 29 base::File* file,
30 // TODO(mcasas): Create() should return a scoped_ptr<> http://crbug.com/321613 30 media::VideoCaptureFormat* video_format);
31 static VideoCaptureDevice* Create(const Name& device_name); 31 static base::File OpenFileForRead(const base::FilePath& file_path);
32 static void GetDeviceNames(Names* device_names); 32
33 static void GetDeviceSupportedFormats(const Name& device, 33 // Constructor of the class, with a fully qualified file path as input, which
34 VideoCaptureFormats* supported_formats); 34 // represents the Y4M video file to stream repeatedly.
35 explicit FileVideoCaptureDevice(const base::FilePath& file_path);
35 36
36 // VideoCaptureDevice implementation, class methods. 37 // VideoCaptureDevice implementation, class methods.
37 virtual ~FileVideoCaptureDevice(); 38 virtual ~FileVideoCaptureDevice();
38 virtual void AllocateAndStart( 39 virtual void AllocateAndStart(
39 const VideoCaptureParams& params, 40 const VideoCaptureParams& params,
40 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE; 41 scoped_ptr<VideoCaptureDevice::Client> client) OVERRIDE;
41 virtual void StopAndDeAllocate() OVERRIDE; 42 virtual void StopAndDeAllocate() OVERRIDE;
42 43
43 private: 44 private:
44 // Constructor of the class, with a fully qualified file path as input, which
45 // represents the Y4M video file to stream repeatedly.
46 explicit FileVideoCaptureDevice(const base::FilePath& file_path);
47 // Returns size in bytes of an I420 frame, not including possible paddings, 45 // Returns size in bytes of an I420 frame, not including possible paddings,
48 // defined by |capture_format_|. 46 // defined by |capture_format_|.
49 int CalculateFrameSize(); 47 int CalculateFrameSize();
50 48
51 // Called on the |capture_thread_|. 49 // Called on the |capture_thread_|.
52 void OnAllocateAndStart(const VideoCaptureParams& params, 50 void OnAllocateAndStart(const VideoCaptureParams& params,
53 scoped_ptr<Client> client); 51 scoped_ptr<Client> client);
54 void OnStopAndDeAllocate(); 52 void OnStopAndDeAllocate();
55 void OnCaptureTask(); 53 void OnCaptureTask();
56 54
(...skipping 13 matching lines...) Expand all
70 int frame_size_; 68 int frame_size_;
71 int64 current_byte_index_; 69 int64 current_byte_index_;
72 int64 first_frame_byte_index_; 70 int64 first_frame_byte_index_;
73 71
74 DISALLOW_COPY_AND_ASSIGN(FileVideoCaptureDevice); 72 DISALLOW_COPY_AND_ASSIGN(FileVideoCaptureDevice);
75 }; 73 };
76 74
77 } // namespace media 75 } // namespace media
78 76
79 #endif // MEDIA_VIDEO_CAPTURE_FILE_VIDEO_CAPTURE_DEVICE_H_ 77 #endif // MEDIA_VIDEO_CAPTURE_FILE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698