summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/video_writer.h
blob: 0b878c458c218f0d7654624a8f40c8d26b364c0f (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
61
62
63
64
65
66
67
68
69
// Copyright (c) 2013 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_VIDEO_WRITER_H_
#define PPAPI_CPP_VIDEO_WRITER_H_

#include <string>

#include "ppapi/c/pp_time.h"
#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/pass_ref.h"
#include "ppapi/cpp/resource.h"

/// @file
/// This file defines the API to create and use video stream readers and
/// writers.

namespace pp {

class InstanceHandle;
class VideoFrame;

// VideoWriter -----------------------------------------------------------------

/// The <code>VideoWriter</code> class represents a video writer resource.
class VideoWriter : public Resource {
 public:
  /// Default constructor for creating a <code>VideoWriter</code> object.
  VideoWriter();

  /// Constructor for creating a <code>VideoWriter</code> for an instance.
  explicit VideoWriter(const InstanceHandle& instance);

  /// The copy constructor for <code>VideoWriter</code>.
  ///
  /// @param[in] other A reference to a <code>VideoWriter</code>.
  VideoWriter(const VideoWriter& other);

  /// A constructor used when you have received a PP_Resource as a return
  /// value that has had its reference count incremented for you.
  ///
  /// @param[in] resource A PP_Resource corresponding to a video writer.
  VideoWriter(PassRef, PP_Resource resource);

  /// Opens a stream for writing video and associates it with the given id.
  ///
  /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
  /// called upon completion of Open which writes the stream id generated by
  /// the host.
  ///
  /// @return A return code from <code>pp_errors.h</code>.
  int32_t Open(const CompletionCallbackWithOutput<Var>& cc);

  /// Puts the next frame of video to the writer's stream.
  ///
  /// @param[in] frame A <code>VideoFrame</code> containing the frame to write
  /// to the open stream.
  ///
  /// @return A return code from <code>pp_errors.h</code>.
  int32_t PutFrame(const VideoFrame& frame);

  /// Closes the writer's current stream.
  void Close();
};

}  // namespace pp

#endif  // PPAPI_CPP_VIDEO_WRITER_H_