예제 #1
0
 /**
  * Create() allocates an image data resource with the given format and size.
  *
  * For security reasons, if uninitialized, the bitmap will not contain random
  * memory, but may contain data from a previous image produced by the same
  * module if the bitmap was cached and re-used.
  *
  * @param[in] instance A <code>PP_Instance</code> identifying one instance
  * of a module.
  * @param[in] format The desired image data format.
  * @param[in] size A pointer to a <code>PP_Size</code> containing the image
  * size.
  * @param[in] init_to_zero A <code>PP_Bool</code> to determine transparency
  * at creation.
  * Set the <code>init_to_zero</code> flag if you want the bitmap initialized
  * to transparent during the creation process. If this flag is not set, the
  * current contents of the bitmap will be undefined, and the module should
  * be sure to set all the pixels.
  *
  * @return A <code>PP_Resource</code> with a nonzero ID on success or zero on
  * failure. Failure means the instance, image size, or format was invalid.
  */
 public static PPResource Create(PPInstance instance,
                                 PPImageDataFormat format,
                                 PPSize size,
                                 PPBool init_to_zero)
 {
     return(_Create(instance, format, size, init_to_zero));
 }
예제 #2
0
 extern static int _Initialize(PPResource video_encoder,
                               PPVideoFrameFormat input_format,
                               PPSize input_visible_size,
                               PPVideoProfile output_profile,
                               uint initial_bitrate,
                               PPHardwareAcceleration acceleration,
                               PPCompletionCallback callback);
예제 #3
0
 /// <summary>
 /// Initializes a video encoder resource asynchronously. This should be called after
 /// GetSupportedProfiles() and before any functions below.
 /// </summary>
 /// <param name="inputFormat">The <code>VideoFrame_Format</code> of the
 /// frames which will be encoded.</param>
 /// <param name="inputVisibleSize">A <code>Size</code> specifying the
 /// dimensions of the visible part of the input frames.</param>
 /// <param name="outputProfile">A <code>VideoProfile</code> specifying the
 /// codec profile of the encoded output stream.</param>
 /// <param name="initialBitrate">The initial bitrate of the encoded output stream</param>
 /// <param name="acceleration">A <code>HardwareAcceleration</code> specifying
 /// whether to use a hardware accelerated or a software implementation.</param>
 /// <param name="messageLoop">Optional MessageLoop instance that can be used to post the command to</param>
 /// <returns>Error code.  Returns NotSupported if video encoding is not available, or the
 /// requested codec profile is not supported.
 /// Returns NoMemory if frame and bitstream buffers can't be created.</returns>
 public Task <PPError> InitializeAsync(VideoFrameFormat inputFormat,
                                       PPSize inputVisibleSize,
                                       VideoProfile outputProfile,
                                       uint initialBitrate,
                                       HardwareAcceleration acceleration,
                                       MessageLoop messageLoop = null)
 => InitializeAsyncCore(inputFormat, inputVisibleSize, outputProfile, initialBitrate, acceleration, messageLoop);
예제 #4
0
 /// <summary>
 /// A constructor allocating a new 2D graphics context with the given size
 /// in the browser, resulting object will be IsEmpty if the allocation
 /// failed.
 ///
 /// </summary>
 /// <param name="instance">The instance with which this resource will be associated.</param>
 /// <param name="size">The size of the 2D graphics context in the browser, measured in pixels. See <code>Scale</code> for more information.</param>
 /// <param name="isAlwaysOpaque">Set the <code>isAlwaysOpaque</code> flag
 /// to true if you know that you will be painting only opaque data to this
 /// context. This option will disable blending when compositing the module
 /// with the web page, which might give higher performance on some computers.
 ///
 /// If you set <code>isAlwaysOpaque</code>, your alpha channel should
 /// always be set to 0xFF or there may be painting artifacts. The alpha values
 /// overwrite the destination alpha values without blending when
 /// <code>isAlwaysOpaque</code> is true.
 /// </param>
 public Graphics2D(Instance instance, PPSize size, bool isAlwaysOpaque)
 {
     handle = PPBGraphics2D.Create(instance, size, (isAlwaysOpaque) ? PPBool.True : PPBool.False);
     if (!handle.IsEmpty)
     {
         Size = size;
     }
 }
예제 #5
0
 /// <summary>
 /// Initializes a video encoder resource. This should be called after
 /// GetSupportedProfiles() and before any functions below.
 /// </summary>
 /// <param name="inputFormat">The <code>VideoFrame_Format</code> of the
 /// frames which will be encoded.</param>
 /// <param name="inputVisibleSize">A <code>Size</code> specifying the
 /// dimensions of the visible part of the input frames.</param>
 /// <param name="outputProfile">A <code>VideoProfile</code> specifying the
 /// codec profile of the encoded output stream.</param>
 /// <param name="initialBitrate">The initial bitrate of the encoded output stream</param>
 /// <param name="acceleration">A <code>HardwareAcceleration</code> specifying
 /// whether to use a hardware accelerated or a software implementation.</param>
 /// <returns>Error code.  Returns NotSupported if video encoding is not available, or the
 /// requested codec profile is not supported.
 /// Returns NoMemory if frame and bitstream buffers can't be created.</returns>
 public PPError Initialize(VideoFrameFormat inputFormat,
                           PPSize inputVisibleSize,
                           VideoProfile outputProfile,
                           uint initialBitrate,
                           HardwareAcceleration acceleration)
 => (PPError)PPBVideoEncoder.Initialize(this, (PPVideoFrameFormat)inputFormat,
                                        inputVisibleSize,
                                        (PPVideoProfile)outputProfile,
                                        initialBitrate,
                                        (PPHardwareAcceleration)acceleration, new CompletionCallback(OnInitialize));
예제 #6
0
 /// <summary>
 /// A constructor that allocates a new <code>ImageData</code> in the browser
 /// with the provided parameters. The resulting object will be IsEmpty if
 /// the allocation failed.
 /// </summary>
 /// <param name="instance">The instance with which this resource will be
 /// associated.
 /// </param>
 /// <param name="format">A PP_ImageDataFormat containing desired image format.
 /// PP_ImageDataFormat is an enumeration of the different types of
 /// image data formats.
 /// </param>
 /// <param name="size">the image size.</param>
 /// <param name="init_to_zero">A bool used to determine transparency at
 /// creation. Set the <code>init_to_zero</code> flag if you want the bitmap
 /// initialized to transparent during the creation process. If this flag is
 /// not set, the current contents of the bitmap will be undefined, and the
 /// module should be sure to set all the pixels.
 /// </param>
 public ImageData(Instance instance,
                  PPImageDataFormat format,
                  PPSize size,
                  bool init_to_zero)
 {
     handle = PPBImageData.Create(instance, format, size, init_to_zero ? PPBool.True : PPBool.False);
     if (PPBImageData.IsImageData(handle) == PPBool.True)
     {
         InitData();
     }
 }
예제 #7
0
파일: PPSize.cs 프로젝트: vzolotov/WebSharp
        public override bool Equals(object obj)
        {
            if (!(obj is PPSize))
            {
                return(false);
            }

            PPSize comp = (PPSize)obj;

            return((comp.width == this.width) &&
                   (comp.height == this.height));
        }
예제 #8
0
        private async Task <PPError> InitializeAsyncCore(VideoFrameFormat inputFormat,
                                                         PPSize inputVisibleSize,
                                                         VideoProfile outputProfile,
                                                         uint initialBitrate,
                                                         HardwareAcceleration acceleration,
                                                         MessageLoop messageLoop = null)
        {
            var tcs = new TaskCompletionSource <PPError>();
            EventHandler <PPError> handler = (s, e) => { tcs.TrySetResult(e); };

            try
            {
                HandleInitialize += handler;

                if (MessageLoop == null && messageLoop == null)
                {
                    Initialize(inputFormat, inputVisibleSize, outputProfile, initialBitrate, acceleration);
                }
                else
                {
                    Action <PPError> action = new Action <PPError>((e) =>
                    {
                        var result = (PPError)PPBVideoEncoder.Initialize(this,
                                                                         (PPVideoFrameFormat)inputFormat,
                                                                         inputVisibleSize,
                                                                         (PPVideoProfile)outputProfile,
                                                                         initialBitrate,
                                                                         (PPHardwareAcceleration)acceleration,
                                                                         new BlockUntilComplete()
                                                                         );
                        tcs.TrySetResult(result);
                    }
                                                                   );

                    InvokeHelper(action, messageLoop);
                }
                return(await tcs.Task);
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                tcs.SetException(exc);
                return(PPError.Aborted);
            }
            finally
            {
                HandleInitialize -= handler;
            }
        }
예제 #9
0
 /**
  * Initializes a video encoder resource. The plugin should call Initialize()
  * successfully before calling any of the functions below.
  *
  * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
  * encoder.
  * @param[in] input_format The <code>PP_VideoFrame_Format</code> of the
  * frames which will be encoded.
  * @param[in] input_visible_size A <code>PP_Size</code> specifying the
  * dimensions of the visible part of the input frames.
  * @param[in] output_profile A <code>PP_VideoProfile</code> specifying the
  * codec profile of the encoded output stream.
  * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying
  * whether to use a hardware accelerated or a software implementation.
  * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
  * completion.
  *
  * @return An int32_t containing an error code from <code>pp_errors.h</code>.
  * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the
  * requested codec profile is not supported.
  */
 public static int Initialize(PPResource video_encoder,
                              PPVideoFrameFormat input_format,
                              PPSize input_visible_size,
                              PPVideoProfile output_profile,
                              uint initial_bitrate,
                              PPHardwareAcceleration acceleration,
                              PPCompletionCallback callback)
 {
     return(_Initialize(video_encoder,
                        input_format,
                        input_visible_size,
                        output_profile,
                        initial_bitrate,
                        acceleration,
                        callback));
 }
예제 #10
0
 /**
  * Gets the size of the video frame.
  *
  * @param[in] frame A <code>PP_Resource</code> corresponding to a video frame
  * resource.
  * @param[out] size A <code>PP_Size</code>.
  *
  * @return A <code>PP_Bool</code> with <code>PP_TRUE</code> on success or
  * <code>PP_FALSE</code> on failure.
  */
 public static PPBool GetSize(PPResource frame, out PPSize size)
 {
     return(_GetSize(frame, out size));
 }
예제 #11
0
 extern static PPBool _GetSize(PPResource frame, out PPSize size);
예제 #12
0
 public PPRect(PPSize size)
     : this(size.Width, size.Height)
 {
 }
예제 #13
0
 /**
  * GetScreenSize() gets the size of the screen in pixels. The module instance
  * will be resized to this size when SetFullscreen() is called to enter
  * fullscreen mode.
  *
  * @param[in] instance A <code>PP_Instance</code> identifying one instance
  * of a module.
  * @param[out] size The size of the entire screen in pixels.
  *
  * @return <code>PP_TRUE</code> on success or <code>PP_FALSE</code> on
  * failure.
  */
 public static PPBool GetScreenSize(PPInstance instance, out PPSize size)
 {
     return(_GetScreenSize(instance, out size));
 }
예제 #14
0
 /**
  * Gets the coded size of the video frames required by the encoder. Coded
  * size is the logical size of the input frames, in pixels.  The encoder may
  * have hardware alignment requirements that make this different from
  * |input_visible_size|, as requested in the call to Initialize().
  *
  * @param[in] video_encoder A <code>PP_Resource</code> identifying the video
  * encoder.
  * @param[in] coded_size A <code>PP_Size</code> to hold the coded size.
  * @return An int32_t containing a result code from <code>pp_errors.h</code>.
  * Returns PP_ERROR_FAILED if Initialize() has not successfully completed.
  */
 public static int GetFrameCodedSize(PPResource video_encoder,
                                     out PPSize coded_size)
 {
     return(_GetFrameCodedSize(video_encoder, out coded_size));
 }
예제 #15
0
 extern static int _GetFrameCodedSize(PPResource video_encoder,
                                      out PPSize coded_size);
예제 #16
0
 extern static PPBool _GetScreenSize(PPInstance instance, out PPSize size);
예제 #17
0
 /// <summary>
 /// Gets the coded size of the video frames required by the encoder. Coded
 /// size is the logical size of the input frames, in pixels.  The encoder may
 /// have hardware alignment requirements that make this different from
 /// |inputVisibleSize|, as requested in the call to Initialize().
 /// </summary>
 /// <param name="codedSize"></param>
 /// <returns>Returns Failed if Initialize has not been called</returns>
 public PPError GetFrameCodedSize(out PPSize codedSize)
 {
     return((PPError)PPBVideoEncoder.GetFrameCodedSize(this, out codedSize));
 }
예제 #18
0
 extern static PPResource _Create(PPInstance instance,
                                  PPImageDataFormat format,
                                  PPSize size,
                                  PPBool init_to_zero);
예제 #19
0
 extern static PPResource _Create(PPInstance instance,
                                  PPSize size,
                                  PPBool is_always_opaque);
예제 #20
0
 public PPRect(PPPoint origin, PPSize size)
     : this(origin.X, origin.Y, size.Width, size.Height)
 {
 }
예제 #21
0
 /**
  * Create() creates a 2D graphics context. The returned graphics context will
  * not be bound to the module instance on creation (call BindGraphics() on
  * the module instance to bind the returned graphics context to the module
  * instance).
  *
  * @param[in] instance The module instance.
  * @param[in] size The size of the graphic context.
  * @param[in] is_always_opaque Set the <code>is_always_opaque</code> flag to
  * <code>PP_TRUE</code> if you know that you will be painting only opaque
  * data to this context. This option will disable blending when compositing
  * the module with the web page, which might give higher performance on some
  * computers.
  *
  * If you set <code>is_always_opaque</code>, your alpha channel should always
  * be set to 0xFF or there may be painting artifacts. The alpha values
  * overwrite the destination alpha values without blending when
  * <code>is_always_opaque</code> is true.
  *
  * @return A <code>PP_Resource</code> containing the 2D graphics context if
  * successful or 0 if unsuccessful.
  */
 public static PPResource Create(PPInstance instance,
                                 PPSize size,
                                 PPBool is_always_opaque)
 {
     return(_Create(instance, size, is_always_opaque));
 }
예제 #22
0
파일: PPSize.cs 프로젝트: vzolotov/WebSharp
 public PPSize(PPSize other)
 {
     width  = other.Width;
     height = other.Height;
 }
예제 #23
0
 extern static PPBool _Describe(PPResource graphics_2d,
                                out PPSize size,
                                out PPBool is_always_opaque);
예제 #24
0
 /// <summary>
 /// Gets the size of the video frame.
 /// </summary>
 /// <param name="size">A size</param>
 /// <returns>True on success or false on failure.</returns>
 public bool GetSize(out PPSize size)
 => PPBVideoFrame.GetSize(this, out size) == PPBool.True;
예제 #25
0
 /**
  * Describe() retrieves the configuration for the given graphics context,
  * filling the given values (which must not be <code>NULL</code>).
  *
  * @param[in] resource The 2D Graphics resource.
  * @param[in,out] size The size of the 2D graphics context in the browser.
  * @param[in,out] is_always_opaque Identifies whether only opaque data
  * will be painted.
  *
  * @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code> if
  * the resource is invalid. The output parameters will be set to 0 on a
  * <code>PP_FALSE</code>.
  */
 public static PPBool Describe(PPResource graphics_2d,
                               out PPSize size,
                               out PPBool is_always_opaque)
 {
     return(_Describe(graphics_2d, out size, out is_always_opaque));
 }