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 PPAPI_CPP_PRIVATE_VIDEO_SOURCE_PRIVATE_H_
6#define PPAPI_CPP_PRIVATE_VIDEO_SOURCE_PRIVATE_H_
7
8#include <string>
9
10#include "ppapi/c/pp_time.h"
11#include "ppapi/cpp/completion_callback.h"
12#include "ppapi/cpp/pass_ref.h"
13#include "ppapi/cpp/resource.h"
14
15/// @file
16/// This file defines the <code>PPB_VideoSource_Private</code> interface for a
17/// video source resource, which receives video frames from a MediaStream video
18/// track in the browser.
19
20namespace pp {
21
22class InstanceHandle;
23class VideoFrame_Private;
24
25/// The <code>VideoSource_Private</code> class contains methods for creating
26/// video source resources and using them to receive video frames from a
27/// MediaStream video track in the browser.
28class VideoSource_Private : public Resource {
29 public:
30  /// Default constructor for creating a <code>VideoSource_Private</code>
31  /// object.
32  VideoSource_Private();
33
34  /// Constructor for creating a <code>VideoSource_Private</code> for an
35  /// instance.
36  explicit VideoSource_Private(const InstanceHandle& instance);
37
38  /// The copy constructor for <code>VideoSource_Private</code>.
39  ///
40  /// @param[in] other A reference to a <code>VideoSource_Private</code>.
41  VideoSource_Private(const VideoSource_Private& other);
42
43  /// A constructor used when you have received a PP_Resource as a return
44  /// value that has had its reference count incremented for you.
45  ///
46  /// @param[in] resource A PP_Resource corresponding to a video source.
47  VideoSource_Private(PassRef, PP_Resource resource);
48
49  /// Opens a video source for getting frames.
50  ///
51  /// @param[in] stream_url A <code>Var</code> string holding a URL identifying
52  /// a MediaStream.
53  /// @param[in] callback A <code>CompletionCallback</code> to be called upon
54  /// completion of Open().
55  ///
56  /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
57  /// Returns PP_ERROR_BADRESOURCE if source isn't a valid video source.
58  /// Returns PP_ERROR_INPROGRESS if source is already open.
59  /// Returns PP_ERROR_FAILED if the MediaStream doesn't exist or if there is
60  /// some other browser error.
61  int32_t Open(const Var& stream_url,
62               const CompletionCallback& cc);
63
64  /// Gets a frame from the video source. The returned frame is only valid
65  /// until the next call to GetFrame.
66  ///
67  /// @param[out] frame A <code>VideoFrame_Private</code> to hold a video
68  /// frame from the source.
69  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
70  /// called upon completion of ReceiveFrame().
71  ///
72  /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
73  /// Returns PP_ERROR_BADRESOURCE if source isn't a valid video source.
74  /// Returns PP_ERROR_FAILED if the source is not open, or if some other
75  /// browser error occurs.
76  int32_t GetFrame(
77      const CompletionCallbackWithOutput<VideoFrame_Private>& cc);
78
79  /// Closes the video source.
80  void Close();
81};
82
83}  // namespace pp
84
85#endif  // PPAPI_CPP_PRIVATE_VIDEO_SOURCE_PRIVATE_H_
86