| Index: ppapi/cpp/video_encoder.h
|
| diff --git a/ppapi/cpp/video_encoder.h b/ppapi/cpp/video_encoder.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..76eba99e231895fda4e804bb6ef6c3b2a900f8cd
|
| --- /dev/null
|
| +++ b/ppapi/cpp/video_encoder.h
|
| @@ -0,0 +1,124 @@
|
| +// Copyright (c) 2014 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_ENCODER_H_
|
| +#define PPAPI_CPP_VIDEO_ENCODER_H_
|
| +
|
| +#include "ppapi/c/ppb_video_encoder.h"
|
| +#include "ppapi/cpp/completion_callback.h"
|
| +#include "ppapi/cpp/graphics_3d.h"
|
| +#include "ppapi/cpp/resource.h"
|
| +#include "ppapi/cpp/size.h"
|
| +
|
| +/// @file
|
| +/// This file defines the API to create and use a VideoEncoder resource.
|
| +
|
| +struct PP_FileInfo;
|
| +
|
| +namespace pp {
|
| +
|
| +class InstanceHandle;
|
| +
|
| +/// Video encoder interface.
|
| +///
|
| +/// Typical usage:
|
| +/// - Call Create() to create a new video encoder resource.
|
| +/// - Call Initialize() to initialize it with a 3d graphics context, the
|
| +/// desired codec parameters.
|
| +/// - Call Encode() continuously (waiting for each previous call to complete) to
|
| +/// push video picture to the encoder.
|
| +/// - Call Reset() to quickly stop the encoder and wait for the callback before
|
| +/// restarting encoding.
|
| +/// - To destroy the encoder, the plugin should release all of its references to
|
| +/// it. Any pending callbacks will abort before the encoder is destroyed.
|
| +///
|
| +/// Available video codecs vary by platform.
|
| +class VideoEncoder : public Resource {
|
| + public:
|
| + /// Default constructor for creating an is_null()
|
| + /// <code>VideoEncoder</code> object.
|
| + VideoEncoder();
|
| +
|
| + /// A constructor used to create a <code>VideoEncoder</code> and associate it
|
| + /// with the provided <code>Instance</code>.
|
| + /// @param[in] instance The instance with which this resource will be
|
| + /// associated.
|
| + explicit VideoEncoder(const InstanceHandle& instance);
|
| +
|
| + /// A constructor used to create a <code>VideoEncoder</code> and associate
|
| + /// it with the provided <code>PP_Resource</code>.
|
| + /// @param[in] encoder_resource The resource with which this instance will be
|
| + /// associated.
|
| + explicit VideoEncoder(PP_Resource resource);
|
| +
|
| + /// The copy constructor for <code>VideoEncoder</code>.
|
| + /// @param[in] other A reference to a <code>VideoEncoder</code>.
|
| + VideoEncoder(const VideoEncoder& other);
|
| +
|
| + /// Initializes a video encoder resource. This should be called after Create()
|
| + /// and before any other functions.
|
| + ///
|
| + /// @param[in] context A <code>PP_Resource</code> identifying the OpenGL
|
| + /// context used to access textures.
|
| + /// @param[in] profile A <code>PP_VideoEncoderParams</code> specifying the
|
| + /// video encoding parameters.
|
| + // @param[in] user_data A pointer to a user_data to be passed the |callback|.
|
| + /// @param[in] callback A <code>CompletionCallback</code> to be called on
|
| + /// completion.
|
| + ///
|
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
|
| + /// Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the
|
| + /// requested profile is not supported. In this case, the client may call
|
| + /// Initialize() again with different parameters to find a good configuration.
|
| + int32_t Initialize(
|
| + const Graphics3D& context,
|
| + const PP_VideoEncoderParams& params,
|
| + void* user_data,
|
| + PPB_VideoEncoder_Ready_Func callback);
|
| +
|
| + /// Encodes a picture. The plugin should wait until the encoder signals
|
| + /// completion by returning PP_OK or by running |callback| before calling
|
| + /// Encode() again.
|
| + ///
|
| + /// If the call to Encode() eventually results in a bitstream buffer, the
|
| + /// |encode_id| parameter is copied into the returned buffer. The plugin can
|
| + /// use this to associate bitstream buffers with Encode() calls (e.g. to
|
| + /// assign timestamps) This value is opaque to the API so the plugin is free
|
| + /// to pass any value.
|
| + ///
|
| + /// @param[in] encode_id An optional value, chosen by the plugin, that can be
|
| + /// used to associate calls to Encode() with bitstream buffers returned by
|
| + /// GetBitstreamBuffer().
|
| + /// @param[in] picture A video picture to encode.
|
| + /// @param[in] force_keyframe Force the encoder to produce a key frame.
|
| + /// @param[in] callback A <code>CompletionCallback</code> to be called on
|
| + /// completion.
|
| + ///
|
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
|
| + /// Returns PP_ERROR_FAILED if the encoder isn't initialized or Reset() call
|
| + /// is pending.
|
| + /// Returns PP_ERROR_INPROGRESS if there is another Encode() call pending.
|
| + /// Returns PP_ERROR_ABORTED when Reset() is called while Encode() is pending.
|
| + int32_t Encode(uint32_t encode_id,
|
| + const PP_VideoEncoderPicture& picture,
|
| + const PP_Bool force_keyframe,
|
| + const CompletionCallback& callback);
|
| +
|
| + /// Resets the encoder as quickly as possible. After Reset() returns, any
|
| + /// pending calls to Encode() or GetBitstreamBuffer() abort, causing their
|
| + /// callbacks to run with PP_ERROR_ABORTED. The plugin should not make further
|
| + /// calls to the encoder until the encoder signals completion by running
|
| + /// |callback|.
|
| + ///
|
| + /// @param[in] callback A <code>CompletionCallback</code> to be called on
|
| + /// completion.
|
| + ///
|
| + /// @return An int32_t containing an error code from <code>pp_errors.h</code>.
|
| + /// Returns PP_ERROR_FAILED if the encoder isn't initialized.
|
| + int32_t Reset(const CompletionCallback& callback);
|
| +};
|
| +
|
| +} // namespace pp
|
| +
|
| +#endif // PPAPI_CPP_VIDEO_ENCODER_H_
|
|
|