LCOV - code coverage report
Current view: top level - dom/media/gmp/gmp-api - gmp-video-encode.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* Copyright (c) 2011, The WebRTC project authors. All rights reserved.
       3             :  * Copyright (c) 2014, Mozilla
       4             :  *
       5             :  * Redistribution and use in source and binary forms, with or without
       6             :  * modification, are permitted provided that the following conditions are
       7             :  * met:
       8             :  *
       9             :  ** Redistributions of source code must retain the above copyright
      10             :  *  notice, this list of conditions and the following disclaimer.
      11             :  *
      12             :  ** Redistributions in binary form must reproduce the above copyright
      13             :  *  notice, this list of conditions and the following disclaimer in
      14             :  *  the documentation and/or other materials provided with the
      15             :  *  distribution.
      16             :  *
      17             :  ** Neither the name of Google nor the names of its contributors may
      18             :  *  be used to endorse or promote products derived from this software
      19             :  *  without specific prior written permission.
      20             :  *
      21             :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      22             :  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      23             :  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      24             :  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
      25             :  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
      26             :  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
      27             :  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
      28             :  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      29             :  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
      30             :  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
      31             :  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      32             :  */
      33             : 
      34             : #ifndef GMP_VIDEO_ENCODE_h_
      35             : #define GMP_VIDEO_ENCODE_h_
      36             : 
      37             : #include <vector>
      38             : #include <stdint.h>
      39             : 
      40             : #include "gmp-errors.h"
      41             : #include "gmp-video-frame-i420.h"
      42             : #include "gmp-video-frame-encoded.h"
      43             : #include "gmp-video-codec.h"
      44             : 
      45             : // ALL METHODS MUST BE CALLED ON THE MAIN THREAD
      46           0 : class GMPVideoEncoderCallback
      47             : {
      48             : public:
      49           0 :   virtual ~GMPVideoEncoderCallback() {}
      50             : 
      51             :   virtual void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
      52             :                        const uint8_t* aCodecSpecificInfo,
      53             :                        uint32_t aCodecSpecificInfoLength) = 0;
      54             : 
      55             :   // Called when the encoder encounters a catestrophic error and cannot
      56             :   // continue. Gecko will not send any more input for encoding.
      57             :   virtual void Error(GMPErr aError) = 0;
      58             : };
      59             : 
      60             : #define GMP_API_VIDEO_ENCODER "encode-video"
      61             : 
      62             : // Video encoding for a single stream. A GMP may be asked to create multiple
      63             : // encoders concurrently.
      64             : //
      65             : // API name macro: GMP_API_VIDEO_ENCODER
      66             : // Host API: GMPVideoHost
      67             : //
      68             : // ALL METHODS MUST BE CALLED ON THE MAIN THREAD
      69             : class GMPVideoEncoder
      70             : {
      71             : public:
      72             :   virtual ~GMPVideoEncoder() {}
      73             : 
      74             :   // Initialize the encoder with the information from the VideoCodec.
      75             :   //
      76             :   // Input:
      77             :   // - codecSettings : Codec settings
      78             :   // - aCodecSpecific : codec specific data, pointer to a
      79             :   //                    GMPCodecSpecific structure appropriate for
      80             :   //                    this codec type.
      81             :   // - aCodecSpecificLength : number of bytes in aCodecSpecific
      82             :   // - aCallback: Subclass should retain reference to it until EncodingComplete
      83             :   //              is called. Do not attempt to delete it, host retains ownership.
      84             :   // - aNnumberOfCores : Number of cores available for the encoder
      85             :   // - aMaxPayloadSize : The maximum size each payload is allowed
      86             :   //                    to have. Usually MTU - overhead.
      87             :   virtual void InitEncode(const GMPVideoCodec& aCodecSettings,
      88             :                           const uint8_t* aCodecSpecific,
      89             :                           uint32_t aCodecSpecificLength,
      90             :                           GMPVideoEncoderCallback* aCallback,
      91             :                           int32_t aNumberOfCores,
      92             :                           uint32_t aMaxPayloadSize) = 0;
      93             : 
      94             :   // Encode an I420 frame (as a part of a video stream). The encoded frame
      95             :   // will be returned to the user through the encode complete callback.
      96             :   //
      97             :   // Input:
      98             :   // - aInputFrame : Frame to be encoded
      99             :   // - aCodecSpecificInfo : codec specific data, pointer to a
     100             :   //                        GMPCodecSpecificInfo structure appropriate for
     101             :   //                        this codec type.
     102             :   // - aCodecSpecificInfoLength : number of bytes in aCodecSpecific
     103             :   // - aFrameTypes : The frame type to encode
     104             :   // - aFrameTypesLength : The number of elements in aFrameTypes array.
     105             :   virtual void Encode(GMPVideoi420Frame* aInputFrame,
     106             :                       const uint8_t* aCodecSpecificInfo,
     107             :                       uint32_t aCodecSpecificInfoLength,
     108             :                       const GMPVideoFrameType* aFrameTypes,
     109             :                       uint32_t aFrameTypesLength) = 0;
     110             : 
     111             :   // Inform the encoder about the packet loss and round trip time on the
     112             :   // network used to decide the best pattern and signaling.
     113             :   //
     114             :   // - packetLoss : Fraction lost (loss rate in percent =
     115             :   // 100 * packetLoss / 255)
     116             :   // - rtt : Round-trip time in milliseconds
     117             :   virtual void SetChannelParameters(uint32_t aPacketLoss, uint32_t aRTT) = 0;
     118             : 
     119             :   // Inform the encoder about the new target bit rate.
     120             :   //
     121             :   // - newBitRate : New target bit rate
     122             :   // - frameRate : The target frame rate
     123             :   virtual void SetRates(uint32_t aNewBitRate, uint32_t aFrameRate) = 0;
     124             : 
     125             :   // Use this function to enable or disable periodic key frames. Can be useful for codecs
     126             :   // which have other ways of stopping error propagation.
     127             :   //
     128             :   // - enable : Enable or disable periodic key frames
     129             :   virtual void SetPeriodicKeyFrames(bool aEnable) = 0;
     130             : 
     131             :   // May free Encoder memory.
     132             :   virtual void EncodingComplete() = 0;
     133             : };
     134             : 
     135             : #endif // GMP_VIDEO_ENCODE_h_

Generated by: LCOV version 1.13