Home | History | Annotate | Download | only in private
      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 
     20 namespace pp {
     21 
     22 class InstanceHandle;
     23 class 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.
     28 class 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.
     65   ///
     66   /// @param[out] frame A <code>VideoFrame_Private</code> to hold a video
     67   /// frame from the source.
     68   /// @param[in] callback A <code>CompletionCallbackWithOutput</code> to be
     69   /// called upon completion of ReceiveFrame().
     70   ///
     71   /// @return An int32_t containing a result code from <code>pp_errors.h</code>.
     72   /// Returns PP_ERROR_BADRESOURCE if source isn't a valid video source.
     73   /// Returns PP_ERROR_FAILED if the source is not open, or if some other
     74   /// browser error occurs.
     75   int32_t GetFrame(
     76       const CompletionCallbackWithOutput<VideoFrame_Private>& cc);
     77 
     78   /// Closes the video source.
     79   void Close();
     80 };
     81 
     82 }  // namespace pp
     83 
     84 #endif  // PPAPI_CPP_PRIVATE_VIDEO_SOURCE_PRIVATE_H_
     85