summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/dev/video_capture_dev.h
blob: 1760cf745cf7ea19f45f8825472e978d442f0b9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_
#define PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_

#include <vector>

#include "ppapi/c/dev/pp_video_capture_dev.h"
#include "ppapi/cpp/resource.h"

namespace pp {

class CompletionCallback;
class DeviceRef_Dev;
class Instance;

class VideoCapture_Dev : public Resource {
 public:
  explicit VideoCapture_Dev(const Instance& instance);
  VideoCapture_Dev(PP_Resource resource);
  VideoCapture_Dev(const VideoCapture_Dev& other);

  virtual ~VideoCapture_Dev();

  VideoCapture_Dev& operator=(const VideoCapture_Dev& other);

  // Returns true if the required interface is available.
  static bool IsAvailable();

  // |devices| must stay alive until either this VideoCapture_Dev object goes
  // away or |callback| is run.
  int32_t EnumerateDevices(std::vector<DeviceRef_Dev>* devices,
                           const CompletionCallback& callback);
  int32_t Open(const DeviceRef_Dev& device_ref,
               const PP_VideoCaptureDeviceInfo_Dev& requested_info,
               uint32_t buffer_count,
               const CompletionCallback& callback);
  int32_t StartCapture();
  int32_t ReuseBuffer(uint32_t buffer);
  int32_t StopCapture();
  void Close();

 private:
  struct EnumerateDevicesState;

  void AbortEnumerateDevices();

  // |user_data| is an EnumerateDevicesState object. It is this method's
  // responsibility to delete it.
  static void OnEnumerateDevicesComplete(void* user_data, int32_t result);

  // Not owned by this object.
  EnumerateDevicesState* enum_state_;
};

}  // namespace pp

#endif  // PPAPI_CPP_DEV_VIDEO_CAPTURE_DEV_H_