text:
<?php
# Generated by the protocol buffer compiler.  DO NOT EDIT!
# source: google/spanner/v1/transaction.proto

namespace Google\Cloud\Spanner\V1;

use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\RepeatedField;
use Google\Protobuf\Internal\GPBUtil;

/**
 * Message type to initiate a read-only transaction.
 *
 * Generated from protobuf message google.spanner.v1.TransactionOptions.ReadOnly
 */
class TransactionOptions_ReadOnly extends \Google\Protobuf\Internal\Message
{
    /**
     * If true, the Cloud Spanner-selected read timestamp is included in
     * the [Transaction][google.spanner.v1.Transaction] message that describes the transaction.
     *
     * Generated from protobuf field bool return_read_timestamp = 6;
     */
    private $return_read_timestamp = false;
    protected $timestamp_bound;

    public function __construct() {
        \GPBMetadata\Google\Spanner\V1\Transaction::initOnce();
        parent::__construct();
    }

    /**
     * Read at a timestamp where all previously committed transactions
     * are visible.
     *
     * Generated from protobuf field bool strong = 1;
     * @return bool
     */
    public function getStrong()
    {
        return $this->readOneof(1);
    }

    /**
     * Read at a timestamp where all previously committed transactions
     * are visible.
     *
     * Generated from protobuf field bool strong = 1;
     * @param bool $var
     * @return $this
     */
    public function setStrong($var)
    {
        GPBUtil::checkBool($var);
        $this->writeOneof(1, $var);

        return $this;
    }

    /**
     * Executes all reads at a timestamp >= `min_read_timestamp`.
     * This is useful for requesting fresher data than some previous
     * read, or data that is fresh enough to observe the effects of some
     * previously committed transaction whose timestamp is known.
     * Note that this option can only be used in single-use transactions.
     * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
     * Example: `"2014-10-02T15:01:23.045123456Z"`.
     *
     * Generated from protobuf field .google.protobuf.Timestamp min_read_timestamp = 2;
     * @return \Google\Protobuf\Timestamp
     */
    public function getMinReadTimestamp()
    {
        return $this->readOneof(2);
    }

    /**
     * Executes all reads at a timestamp >= `min_read_timestamp`.
     * This is useful for requesting fresher data than some previous
     * read, or data that is fresh enough to observe the effects of some
     * previously committed transaction whose timestamp is known.
     * Note that this option can only be used in single-use transactions.
     * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
     * Example: `"2014-10-02T15:01:23.045123456Z"`.
     *
     * Generated from protobuf field .google.protobuf.Timestamp min_read_timestamp = 2;
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setMinReadTimestamp($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->writeOneof(2, $var);

        return $this;
    }

    /**
     * Read data at a timestamp >= `NOW - max_staleness`
     * seconds. Guarantees that all writes that have committed more
     * than the specified number of seconds ago are visible. Because
     * Cloud Spanner chooses the exact timestamp, this mode works even if
     * the client's local clock is substantially skewed from Cloud Spanner
     * commit timestamps.
     * Useful for reading the freshest data available at a nearby
     * replica, while bounding the possible staleness if the local
     * replica has fallen behind.
     * Note that this option can only be used in single-use
     * transactions.
     *
     * Generated from protobuf field .google.protobuf.Duration max_staleness = 3;
     * @return \Google\Protobuf\Duration
     */
    public function getMaxStaleness()
    {
        return $this->readOneof(3);
    }

    /**
     * Read data at a timestamp >= `NOW - max_staleness`
     * seconds. Guarantees that all writes that have committed more
     * than the specified number of seconds ago are visible. Because
     * Cloud Spanner chooses the exact timestamp, this mode works even if
     * the client's local clock is substantially skewed from Cloud Spanner
     * commit timestamps.
     * Useful for reading the freshest data available at a nearby
     * replica, while bounding the possible staleness if the local
     * replica has fallen behind.
     * Note that this option can only be used in single-use
     * transactions.
     *
     * Generated from protobuf field .google.protobuf.Duration max_staleness = 3;
     * @param \Google\Protobuf\Duration $var
     * @return $this
     */
    public function setMaxStaleness($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class);
        $this->writeOneof(3, $var);

        return $this;
    }

    /**
     * Executes all reads at the given timestamp. Unlike other modes,
     * reads at a specific timestamp are repeatable; the same read at
     * the same timestamp always returns the same data. If the
     * timestamp is in the future, the read will block until the
     * specified timestamp, modulo the read's deadline.
     * Useful for large scale consistent reads such as mapreduces, or
     * for coordinating many reads against a consistent snapshot of the
     * data.
     * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
     * Example: `"2014-10-02T15:01:23.045123456Z"`.
     *
     * Generated from protobuf field .google.protobuf.Timestamp read_timestamp = 4;
     * @return \Google\Protobuf\Timestamp
     */
    public function getReadTimestamp()
    {
        return $this->readOneof(4);
    }

    /**
     * Executes all reads at the given timestamp. Unlike other modes,
     * reads at a specific timestamp are repeatable; the same read at
     * the same timestamp always returns the same data. If the
     * timestamp is in the future, the read will block until the
     * specified timestamp, modulo the read's deadline.
     * Useful for large scale consistent reads such as mapreduces, or
     * for coordinating many reads against a consistent snapshot of the
     * data.
     * A timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds.
     * Example: `"2014-10-02T15:01:23.045123456Z"`.
     *
     * Generated from protobuf field .google.protobuf.Timestamp read_timestamp = 4;
     * @param \Google\Protobuf\Timestamp $var
     * @return $this
     */
    public function setReadTimestamp($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
        $this->writeOneof(4, $var);

        return $this;
    }

    /**
     * Executes all reads at a timestamp that is `exact_staleness`
     * old. The timestamp is chosen soon after the read is started.
     * Guarantees that all writes that have committed more than the
     * specified number of seconds ago are visible. Because Cloud Spanner
     * chooses the exact timestamp, this mode works even if the client's
     * local clock is substantially skewed from Cloud Spanner commit
     * timestamps.
     * Useful for reading at nearby replicas without the distributed
     * timestamp negotiation overhead of `max_staleness`.
     *
     * Generated from protobuf field .google.protobuf.Duration exact_staleness = 5;
     * @return \Google\Protobuf\Duration
     */
    public function getExactStaleness()
    {
        return $this->readOneof(5);
    }

    /**
     * Executes all reads at a timestamp that is `exact_staleness`
     * old. The timestamp is chosen soon after the read is started.
     * Guarantees that all writes that have committed more than the
     * specified number of seconds ago are visible. Because Cloud Spanner
     * chooses the exact timestamp, this mode works even if the client's
     * local clock is substantially skewed from Cloud Spanner commit
     * timestamps.
     * Useful for reading at nearby replicas without the distributed
     * timestamp negotiation overhead of `max_staleness`.
     *
     * Generated from protobuf field .google.protobuf.Duration exact_staleness = 5;
     * @param \Google\Protobuf\Duration $var
     * @return $this
     */
    public function setExactStaleness($var)
    {
        GPBUtil::checkMessage($var, \Google\Protobuf\Duration::class);
        $this->writeOneof(5, $var);

        return $this;
    }

    /**
     * If true, the Cloud Spanner-selected read timestamp is included in
     * the [Transaction][google.spanner.v1.Transaction] message that describes the transaction.
     *
     * Generated from protobuf field bool return_read_timestamp = 6;
     * @return bool
     */
    public function getReturnReadTimestamp()
    {
        return $this->return_read_timestamp;
    }

    /**
     * If true, the Cloud Spanner-selected read timestamp is included in
     * the [Transaction][google.spanner.v1.Transaction] message that describes the transaction.
     *
     * Generated from protobuf field bool return_read_timestamp = 6;
     * @param bool $var
     * @return $this
     */
    public function setReturnReadTimestamp($var)
    {
        GPBUtil::checkBool($var);
        $this->return_read_timestamp = $var;

        return $this;
    }

    /**
     * @return string
     */
    public function getTimestampBound()
    {
        return $this->whichOneof("timestamp_bound");
    }

}


text:
using System;

namespace LinqInfer.Utility
{
    public interface IStopwatch
    {
        TimeSpan Elapsed { get; }
        bool IsRunning { get; }

        void Reset();
        void Start();
        void Stop();
    }
}

redpajama_set_name: RedPajamaGithub


text:
#include <bmx/clip_writer/ClipWriter.h>
#include <bmx/as02/AS02Version.h>
#include <bmx/Utils.h>
#include <bmx/MXFUtils.h>
#include <bmx/BMXException.h>
#include <bmx/Logging.h>

using namespace std;
using namespace mxfpp;
using namespace bmx;

ClipWriter* ClipWriter::OpenNewAS02Clip(string bundle_directory, bool create_bundle_dir, Rational frame_rate,
                                        MXFFileFactory *file_factory, bool take_factory_ownership)
{
    AS02Bundle *bundle = AS02Bundle::OpenNew(bundle_directory, create_bundle_dir, file_factory, take_factory_ownership);
    return new ClipWriter(bundle, AS02Version::OpenNewPrimary(bundle, frame_rate));
}

ClipWriter* ClipWriter::OpenNewOP1AClip(int flavour, File *file, Rational frame_rate)
{
    return new ClipWriter(new OP1AFile(flavour, file, frame_rate));
}

ClipWriter* ClipWriter::OpenNewAvidClip(int flavour, Rational frame_rate, MXFFileFactory *file_factory,
                                        bool take_factory_ownership, string filename_prefix)
{
    return new ClipWriter(new AvidClip(flavour, frame_rate, file_factory, take_factory_ownership, filename_prefix));
}

ClipWriter* ClipWriter::OpenNewD10Clip(int flavour, File *file, Rational frame_rate)
{
    return new ClipWriter(new D10File(flavour, file, frame_rate));
}

ClipWriter* ClipWriter::OpenNewRDD9Clip(int flavour, File *file, Rational frame_rate)
{
    return new ClipWriter(new RDD9File(flavour, file, frame_rate));
}

ClipWriter* ClipWriter::OpenNewWaveClip(WaveIO *file)
{
    return new ClipWriter(new WaveWriter(file, true));
}

ClipWriter::ClipWriter(AS02Bundle *bundle, AS02Clip *clip)
{
    mType = CW_AS02_CLIP_TYPE;
    mAS02Bundle = bundle;
    mAS02Clip = clip;
    mOP1AClip = 0;
    mAvidClip = 0;
    mD10Clip = 0;
    mRDD9Clip = 0;
    mWaveClip = 0;
}

ClipWriter::ClipWriter(OP1AFile *clip)
{
    mType = CW_OP1A_CLIP_TYPE;
    mAS02Bundle = 0;
    mAS02Clip = 0;
    mOP1AClip = clip;
    mAvidClip = 0;
    mD10Clip = 0;
    mRDD9Clip = 0;
    mWaveClip = 0;
}

ClipWriter::ClipWriter(AvidClip *clip)
{
    mType = CW_AVID_CLIP_TYPE;
    mAS02Bundle = 0;
    mAS02Clip = 0;
    mOP1AClip = 0;
    mAvidClip = clip;
    mD10Clip = 0;
    mRDD9Clip = 0;
    mWaveClip = 0;
}

ClipWriter::ClipWriter(D10File *clip)
{
    mType = CW_D10_CLIP_TYPE;
    mAS02Bundle = 0;
    mAS02Clip = 0;
    mOP1AClip = 0;
    mAvidClip = 0;
    mD10Clip = clip;
    mRDD9Clip = 0;
    mWaveClip = 0;
}

ClipWriter::ClipWriter(RDD9File *clip)
{
    mType = CW_RDD9_CLIP_TYPE;
    mAS02Bundle = 0;
    mAS02Clip = 0;
    mOP1AClip = 0;
    mAvidClip = 0;
    mD10Clip = 0;
    mRDD9Clip = clip;
    mWaveClip = 0;
}

ClipWriter::ClipWriter(WaveWriter *clip)
{
    mType = CW_WAVE_CLIP_TYPE;
    mAS02Bundle = 0;
    mAS02Clip = 0;
    mOP1AClip = 0;
    mAvidClip = 0;
    mD10Clip = 0;
    mRDD9Clip = 0;
    mWaveClip = clip;
}

ClipWriter::~ClipWriter()
{
    delete mAS02Bundle;
    delete mAS02Clip;
    delete mOP1AClip;
    delete mAvidClip;
    delete mD10Clip;
    delete mRDD9Clip;
    delete mWaveClip;

    size_t i;
    for (i = 0; i < mTracks.size(); i++)
        delete mTracks[i];
}

void ClipWriter::SetClipName(string name)
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            mAS02Clip->SetClipName(name);
            break;
        case CW_OP1A_CLIP_TYPE:
            mOP1AClip->SetClipName(name);
            break;
        case CW_AVID_CLIP_TYPE:
            mAvidClip->SetClipName(name);
            break;
        case CW_D10_CLIP_TYPE:
            mD10Clip->SetClipName(name);
            break;
        case CW_RDD9_CLIP_TYPE:
            mRDD9Clip->SetClipName(name);
            break;
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
}

void ClipWriter::SetStartTimecode(Timecode start_timecode)
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            mAS02Clip->SetStartTimecode(start_timecode);
            break;
        case CW_OP1A_CLIP_TYPE:
            mOP1AClip->SetStartTimecode(start_timecode);
            break;
        case CW_AVID_CLIP_TYPE:
            mAvidClip->SetStartTimecode(start_timecode);
            break;
        case CW_D10_CLIP_TYPE:
            mD10Clip->SetStartTimecode(start_timecode);
            break;
        case CW_RDD9_CLIP_TYPE:
            mRDD9Clip->SetStartTimecode(start_timecode);
            break;
        case CW_WAVE_CLIP_TYPE:
            mWaveClip->SetStartTimecode(start_timecode);
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
}

void ClipWriter::SetAuxiliaryTimecodes(const vector<Timecode> &aux_timecodes)
{
    switch (mType)
    {
        case CW_AVID_CLIP_TYPE:
            mAvidClip->SetAuxiliaryTimecodes(aux_timecodes);
            break;
        default:
            break;
    }
}

void ClipWriter::SetProductInfo(string company_name, string product_name, mxfProductVersion product_version,
                                string version, mxfUUID product_uid)
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            mAS02Clip->SetProductInfo(company_name, product_name, product_version, version, product_uid);
            break;
        case CW_OP1A_CLIP_TYPE:
            mOP1AClip->SetProductInfo(company_name, product_name, product_version, version, product_uid);
            break;
        case CW_AVID_CLIP_TYPE:
            mAvidClip->SetProductInfo(company_name, product_name, product_version, version, product_uid);
            break;
        case CW_D10_CLIP_TYPE:
            mD10Clip->SetProductInfo(company_name, product_name, product_version, version, product_uid);
            break;
        case CW_RDD9_CLIP_TYPE:
            mRDD9Clip->SetProductInfo(company_name, product_name, product_version, version, product_uid);
            break;
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
}

void ClipWriter::ReserveHeaderMetadataSpace(uint32_t min_bytes)
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            mAS02Clip->ReserveHeaderMetadataSpace(min_bytes);
            break;
        case CW_OP1A_CLIP_TYPE:
            mOP1AClip->ReserveHeaderMetadataSpace(min_bytes);
            break;
        case CW_D10_CLIP_TYPE:
            mD10Clip->ReserveHeaderMetadataSpace(min_bytes);
            break;
        case CW_RDD9_CLIP_TYPE:
            mRDD9Clip->ReserveHeaderMetadataSpace(min_bytes);
            break;
        case CW_AVID_CLIP_TYPE:
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
}

ClipWriterTrack* ClipWriter::CreateTrack(EssenceType essence_type, string track_filename)
{
    ClipWriterTrack *track = 0;
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            track = new ClipWriterTrack(essence_type, mAS02Clip->CreateTrack(essence_type));
            break;
        case CW_OP1A_CLIP_TYPE:
            track = new ClipWriterTrack(essence_type, mOP1AClip->CreateTrack(essence_type));
            break;
        case CW_AVID_CLIP_TYPE:
            if (track_filename.empty())
                track = new ClipWriterTrack(essence_type, mAvidClip->CreateTrack(essence_type));
            else
                track = new ClipWriterTrack(essence_type, mAvidClip->CreateTrack(essence_type, track_filename));
            break;
        case CW_D10_CLIP_TYPE:
            track = new ClipWriterTrack(essence_type, mD10Clip->CreateTrack(essence_type));
            break;
        case CW_RDD9_CLIP_TYPE:
            track = new ClipWriterTrack(essence_type, mRDD9Clip->CreateTrack(essence_type));
            break;
        case CW_WAVE_CLIP_TYPE:
            BMX_CHECK(essence_type == WAVE_PCM);
            track = new ClipWriterTrack(essence_type, mWaveClip->CreateTrack());
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    mTracks.push_back(track);
    return track;
}

ClipWriterTrack* ClipWriter::CreateXMLTrack()
{
    ClipWriterTrack *track = 0;
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            track = new ClipWriterTrack(mOP1AClip->CreateXMLTrack());
            break;
        case CW_D10_CLIP_TYPE:
            track = new ClipWriterTrack(mD10Clip->CreateXMLTrack());
            break;
        case CW_RDD9_CLIP_TYPE:
            track = new ClipWriterTrack(mRDD9Clip->CreateXMLTrack());
            break;
        case CW_AS02_CLIP_TYPE:
        case CW_AVID_CLIP_TYPE:
        case CW_WAVE_CLIP_TYPE:
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    mTracks.push_back(track);
    return track;
}

void ClipWriter::PrepareHeaderMetadata()
{
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            mOP1AClip->PrepareHeaderMetadata();
            break;
        case CW_D10_CLIP_TYPE:
            mD10Clip->PrepareHeaderMetadata();
            break;
        case CW_RDD9_CLIP_TYPE:
            mRDD9Clip->PrepareHeaderMetadata();
            break;
        case CW_AS02_CLIP_TYPE:
        case CW_AVID_CLIP_TYPE:
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
	//BMX_EXCEPTION(("Clip type not supported for EBU Core embedding"));
}

void ClipWriter::PrepareWrite()
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            mAS02Clip->PrepareWrite();
            break;
        case CW_OP1A_CLIP_TYPE:
            mOP1AClip->PrepareWrite();
            break;
        case CW_AVID_CLIP_TYPE:
            mAvidClip->PrepareWrite();
            break;
        case CW_D10_CLIP_TYPE:
            mD10Clip->PrepareWrite();
            break;
        case CW_RDD9_CLIP_TYPE:
            mRDD9Clip->PrepareWrite();
            break;
        case CW_WAVE_CLIP_TYPE:
            mWaveClip->PrepareWrite();
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
}

void ClipWriter::WriteSamples(uint32_t track_index, const unsigned char *data, uint32_t size, uint32_t num_samples)
{
    ClipWriterTrack *track = GetTrack(track_index);
    track->WriteSamples(data, size, num_samples);
}

void ClipWriter::CompleteWrite()
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            mAS02Clip->CompleteWrite();
            mAS02Bundle->FinalizeBundle();
            break;
        case CW_OP1A_CLIP_TYPE:
            mOP1AClip->CompleteWrite();
            break;
        case CW_AVID_CLIP_TYPE:
            mAvidClip->CompleteWrite();
            break;
        case CW_D10_CLIP_TYPE:
            mD10Clip->CompleteWrite();
            break;
        case CW_RDD9_CLIP_TYPE:
            mRDD9Clip->CompleteWrite();
            break;
        case CW_WAVE_CLIP_TYPE:
            mWaveClip->CompleteWrite();
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
}

HeaderMetadata* ClipWriter::GetHeaderMetadata() const
{
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetHeaderMetadata();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetHeaderMetadata();
        case CW_RDD9_CLIP_TYPE:
            return mRDD9Clip->GetHeaderMetadata();
        case CW_AS02_CLIP_TYPE:
        case CW_AVID_CLIP_TYPE:
			// [TODO] Check this line....
			// return mAvidClip->GetHeaderMetadata();
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
	BMX_EXCEPTION(("Clip type not supported for EBU Core embedding"));

    return 0;
}

DataModel* ClipWriter::GetDataModel() const
{
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetDataModel();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetDataModel();
        case CW_RDD9_CLIP_TYPE:
            return mRDD9Clip->GetDataModel();
        case CW_AS02_CLIP_TYPE:
        case CW_AVID_CLIP_TYPE:
			// [TODO] Check this line....
			// return mAvidClip->GetDataModel();
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }
	BMX_EXCEPTION(("Clip type not supported for EBU Core embedding"));

    return 0;
}

UniqueIdHelper* ClipWriter::GetTrackIdHelper()
{
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetTrackIdHelper();
        case CW_RDD9_CLIP_TYPE:
            return mRDD9Clip->GetTrackIdHelper();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetTrackIdHelper();
        case CW_AS02_CLIP_TYPE:
            return mAS02Clip->GetTrackIdHelper();
        case CW_AVID_CLIP_TYPE:
            return mAvidClip->GetTrackIdHelper();
        case CW_WAVE_CLIP_TYPE:
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    return 0; // for the compiler
}

UniqueIdHelper* ClipWriter::GetStreamIdHelper()
{
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetStreamIdHelper();
        case CW_RDD9_CLIP_TYPE:
            return mRDD9Clip->GetStreamIdHelper();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetStreamIdHelper();
        case CW_AS02_CLIP_TYPE:
            return mAS02Clip->GetStreamIdHelper();
        case CW_AVID_CLIP_TYPE:
            return mAvidClip->GetStreamIdHelper();
        case CW_WAVE_CLIP_TYPE:
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    return 0; // for the compiler
}

Rational ClipWriter::GetFrameRate() const
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            return mAS02Clip->GetFrameRate();
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetFrameRate();
        case CW_AVID_CLIP_TYPE:
            return mAvidClip->GetFrameRate();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetFrameRate();
        case CW_RDD9_CLIP_TYPE:
            return mRDD9Clip->GetFrameRate();
        case CW_WAVE_CLIP_TYPE:
            return mWaveClip->GetSamplingRate();
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    return ZERO_RATIONAL;
}

Timecode ClipWriter::GetStartTimecode() const
{
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetStartTimecode();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetStartTimecode();
        case CW_RDD9_CLIP_TYPE:
            return mRDD9Clip->GetStartTimecode();
        case CW_AS02_CLIP_TYPE:
        case CW_AVID_CLIP_TYPE:
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    return Timecode();
}

int64_t ClipWriter::GetDuration() const
{
    switch (mType)
    {
        case CW_AS02_CLIP_TYPE:
            return mAS02Clip->GetDuration();
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetDuration();
        case CW_AVID_CLIP_TYPE:
            return mAvidClip->GetDuration();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetDuration();
        case CW_RDD9_CLIP_TYPE:
            return mRDD9Clip->GetDuration();
        case CW_WAVE_CLIP_TYPE:
            return mWaveClip->GetDuration();
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    return 0;
}

int64_t ClipWriter::GetInputDuration() const
{
    switch (mType)
    {
        case CW_OP1A_CLIP_TYPE:
            return mOP1AClip->GetInputDuration();
        case CW_D10_CLIP_TYPE:
            return mD10Clip->GetInputDuration();
        case CW_AS02_CLIP_TYPE:
        case CW_AVID_CLIP_TYPE:
        case CW_RDD9_CLIP_TYPE:
        case CW_WAVE_CLIP_TYPE:
            break;
        case CW_UNKNOWN_CLIP_TYPE:
            BMX_ASSERT(false);
            break;
    }

    return -1;
}

ClipWriterTrack* ClipWriter::GetTrack(uint32_t track_index)
{
    BMX_CHECK(track_index < mTracks.size());
    return mTracks[track_index];
}


text:
<!DOCTYPE html>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta content="IE=edge" http-equiv="X-UA-Compatible">

<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" />
<title>AudioFormat - Android SDK | Android Developers</title>

<link rel="stylesheet"
href="http://fonts.googleapis.com/css?family=Roboto+Condensed">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:light,regular,medium,thin,italic,mediumitalic,bold"
  title="roboto">

<link href="../../../assets/css/default.css?v=7" rel="stylesheet" type="text/css">

<link href="../../../assets/css/fullscreen.css" rel="stylesheet" class="fullscreen"
type="text/css">

           Developers

AudioFormat - Android SDK

      <form class="dac-header-search-form" onsubmit="return submit_search()">
        <input id="search_autocomplete" type="text" value="" autocomplete="off" name="q"
          onfocus="search_focus_changed(this, true)" onblur="search_focus_changed(this, false)"
          onkeydown="return search_changed(event, true, '../../../')"
          onkeyup="return search_changed(event, false, '../../../')"
          class="dac-header-search-input" placeholder="Search" />
          close
      </form>

          Developer
          Console

Results

Loading...

           Developers

        Home

            Android

            Wear

            TV

            Auto

        Design

        Develop

            Training

            API Guides

            Reference

            Tools

            Google Services

            Preview

        Distribute

            Google Play

            Essentials

            Get Users

            Engage & Retain

            Earn

            Analyze

            Stories

          API level:

            <select id="apiLevelSelector">

            </select>

Android APIs

  android

  android.accessibilityservice

  android.accounts

  android.animation

  android.annotation

  android.app

  android.app.admin

  android.app.assist

  android.app.backup

  android.app.job

  android.app.usage

  android.appwidget

  android.bluetooth

  android.bluetooth.le

  android.content

  android.content.pm

  android.content.res

  android.database

  android.database.sqlite

  android.databinding

  android.drm

  android.gesture

  android.graphics

  android.graphics.drawable

  android.graphics.drawable.shapes

  android.graphics.pdf

  android.hardware

  android.hardware.camera2

  android.hardware.camera2.params

  android.hardware.display

  android.hardware.fingerprint

  android.hardware.input

  android.hardware.usb

  android.inputmethodservice

  android.location

  android.media

  android.media.audiofx

  android.media.browse

  android.media.effect

  android.media.midi

  android.media.projection

  android.media.session

  android.media.tv

  android.mtp

  android.net

  android.net.http

  android.net.nsd

  android.net.rtp

  android.net.sip

  android.net.wifi

  android.net.wifi.p2p

  android.net.wifi.p2p.nsd

  android.nfc

  android.nfc.cardemulation

  android.nfc.tech

  android.opengl

  android.os

  android.os.storage

  android.preference

  android.print

  android.print.pdf

  android.printservice

  android.provider

  android.renderscript

  android.sax

  android.security

  android.security.keystore

  android.service.carrier

  android.service.chooser

  android.service.dreams

  android.service.media

  android.service.notification

  android.service.restrictions

  android.service.textservice

  android.service.voice

  android.service.wallpaper

  android.speech

  android.speech.tts

  android.support.annotation

  android.support.app.recommendation

  android.support.customtabs

  android.support.design

  android.support.design.widget

  android.support.multidex

  android.support.percent

  android.support.v13.app

  android.support.v14.preference

  android.support.v17.leanback

  android.support.v17.leanback.app

  android.support.v17.leanback.database

  android.support.v17.leanback.graphics

  android.support.v17.leanback.system

  android.support.v17.leanback.widget

  android.support.v17.preference

  android.support.v4.accessibilityservice

  android.support.v4.animation

  android.support.v4.app

  android.support.v4.content

  android.support.v4.content.pm

  android.support.v4.content.res

  android.support.v4.database

  android.support.v4.graphics

  android.support.v4.graphics.drawable

  android.support.v4.hardware.display

  android.support.v4.hardware.fingerprint

  android.support.v4.media

  android.support.v4.media.session

  android.support.v4.net

  android.support.v4.os

  android.support.v4.print

  android.support.v4.provider

  android.support.v4.text

  android.support.v4.util

  android.support.v4.view

  android.support.v4.view.accessibility

  android.support.v4.view.animation

  android.support.v4.widget

  android.support.v7.app

  android.support.v7.appcompat

  android.support.v7.cardview

  android.support.v7.graphics

  android.support.v7.graphics.drawable

  android.support.v7.gridlayout

  android.support.v7.media

  android.support.v7.mediarouter

  android.support.v7.preference

  android.support.v7.recyclerview

  android.support.v7.util

  android.support.v7.view

  android.support.v7.widget

  android.support.v7.widget.helper

  android.support.v7.widget.util

  android.support.v8.renderscript

  android.system

  android.telecom

  android.telephony

  android.telephony.cdma

  android.telephony.gsm

  android.test

  android.test.mock

  android.test.suitebuilder

  android.test.suitebuilder.annotation

  android.text

  android.text.format

  android.text.method

  android.text.style

  android.text.util

  android.transition

  android.util

  android.view

  android.view.accessibility

  android.view.animation

  android.view.inputmethod

  android.view.textservice

  android.webkit

  android.widget

  com.android.internal.backup

  com.android.internal.logging

  com.android.internal.os

  com.android.internal.statusbar

  com.android.internal.widget

  com.android.test.runner

  dalvik.annotation

  dalvik.bytecode

  dalvik.system

  java.awt.font

  java.beans

  java.io

  java.lang

  java.lang.annotation

  java.lang.ref

  java.lang.reflect

  java.math

  java.net

  java.nio

  java.nio.channels

  java.nio.channels.spi

  java.nio.charset

  java.nio.charset.spi

  java.security

  java.security.acl

  java.security.cert

  java.security.interfaces

  java.security.spec

  java.sql

  java.text

  java.util

  java.util.concurrent

  java.util.concurrent.atomic

  java.util.concurrent.locks

  java.util.jar

  java.util.logging

  java.util.prefs

  java.util.regex

  java.util.zip

  javax.crypto

  javax.crypto.interfaces

  javax.crypto.spec

  javax.microedition.khronos.egl

  javax.microedition.khronos.opengles

  javax.net

  javax.net.ssl

  javax.security.auth

  javax.security.auth.callback

  javax.security.auth.login

  javax.security.auth.x500

  javax.security.cert

  javax.sql

  javax.xml

  javax.xml.datatype

  javax.xml.namespace

  javax.xml.parsers

  javax.xml.transform

  javax.xml.transform.dom

  javax.xml.transform.sax

  javax.xml.transform.stream

  javax.xml.validation

  javax.xml.xpath

  junit.framework

  junit.runner

  org.apache.http.conn

  org.apache.http.conn.scheme

  org.apache.http.conn.ssl

  org.apache.http.params

  org.json

  org.w3c.dom

  org.w3c.dom.ls

  org.xml.sax

  org.xml.sax.ext

  org.xml.sax.helpers

  org.xmlpull.v1

  org.xmlpull.v1.sax2

Interfaces

AudioManager.OnAudioFocusChangeListener

AudioRecord.OnRecordPositionUpdateListener

AudioRecord.OnRoutingChangedListener

AudioTrack.OnPlaybackPositionUpdateListener

AudioTrack.OnRoutingChangedListener

ImageReader.OnImageAvailableListener

ImageWriter.OnImageReleasedListener

JetPlayer.OnJetEventListener

MediaCodec.OnFrameRenderedListener

MediaDrm.OnEventListener

MediaDrm.OnExpirationUpdateListener

MediaDrm.OnKeyStatusChangeListener

MediaPlayer.OnBufferingUpdateListener

MediaPlayer.OnCompletionListener

MediaPlayer.OnErrorListener

MediaPlayer.OnInfoListener

MediaPlayer.OnPreparedListener

MediaPlayer.OnSeekCompleteListener

MediaPlayer.OnTimedMetaDataAvailableListener

MediaPlayer.OnTimedTextListener

MediaPlayer.OnVideoSizeChangedListener

MediaRecorder.OnErrorListener

MediaRecorder.OnInfoListener

MediaScannerConnection.MediaScannerConnectionClient

MediaScannerConnection.OnScanCompletedListener

MediaSync.OnErrorListener

RemoteControlClient.OnGetPlaybackPositionListener

RemoteControlClient.OnMetadataUpdateListener

RemoteControlClient.OnPlaybackPositionUpdateListener

RemoteController.OnClientUpdateListener

SoundPool.OnLoadCompleteListener

Classes

AsyncPlayer

AudioAttributes

AudioAttributes.Builder

AudioDeviceCallback

AudioDeviceInfo

AudioFormat

AudioFormat.Builder

AudioManager

AudioRecord

AudioRecord.Builder

AudioTimestamp

AudioTrack

AudioTrack.Builder

CamcorderProfile

CameraProfile

ExifInterface

FaceDetector

FaceDetector.Face

Image

Image.Plane

ImageReader

ImageWriter

JetPlayer

MediaActionSound

MediaCodec

MediaCodec.BufferInfo

MediaCodec.Callback

MediaCodec.CryptoInfo

MediaCodecInfo

MediaCodecInfo.AudioCapabilities

MediaCodecInfo.CodecCapabilities

MediaCodecInfo.CodecProfileLevel

MediaCodecInfo.EncoderCapabilities

MediaCodecInfo.VideoCapabilities

MediaCodecList

MediaCrypto

MediaDataSource

MediaDescription

MediaDescription.Builder

MediaDrm

MediaDrm.CryptoSession

MediaDrm.KeyRequest

MediaDrm.KeyStatus

MediaDrm.ProvisionRequest

MediaExtractor

MediaFormat

MediaMetadata

MediaMetadata.Builder

MediaMetadataEditor

MediaMetadataRetriever

MediaMuxer

MediaMuxer.OutputFormat

MediaPlayer

MediaPlayer.TrackInfo

MediaRecorder

MediaRecorder.AudioEncoder

MediaRecorder.AudioSource

MediaRecorder.OutputFormat

MediaRecorder.VideoEncoder

MediaRecorder.VideoSource

MediaRouter

MediaRouter.Callback

MediaRouter.RouteCategory

MediaRouter.RouteGroup

MediaRouter.RouteInfo

MediaRouter.SimpleCallback

MediaRouter.UserRouteInfo

MediaRouter.VolumeCallback

MediaScannerConnection

MediaSync

MediaSync.Callback

MediaSyncEvent

MediaTimestamp

PlaybackParams

Rating

RemoteControlClient

RemoteControlClient.MetadataEditor

RemoteController

RemoteController.MetadataEditor

Ringtone

RingtoneManager

SoundPool

SoundPool.Builder

SyncParams

ThumbnailUtils

TimedMetaData

TimedText

ToneGenerator

VolumeProvider

Exceptions

DeniedByServerException

MediaCodec.CodecException

MediaCodec.CryptoException

MediaCryptoException

MediaDrm.MediaDrmStateException

MediaDrmException

MediaDrmResetException

NotProvisionedException

ResourceBusyException

UnsupportedSchemeException

      fullscreen
      Use Tree NavigationUse Panel Navigation

Summary:

  Nested Classes

  | Constants

  | Methods

  | Inherited Methods

| [Expand All]

  Added in API level 3

    public

    class

AudioFormat

    extends Object

        java.lang.Object

               ↳

        android.media.AudioFormat

Class Overview

The AudioFormat class is used to access a number of audio format and
 channel configuration constants. They are for instance used
 in AudioTrack and AudioRecord, as valid values in individual parameters of
 constructors like AudioTrack(int, int, int, int, int, int), where the fourth
 parameter is one of the AudioFormat.ENCODING_* constants.
 The AudioFormat constants are also used in MediaFormat to specify
 audio related values commonly used in media, such as for KEY_CHANNEL_MASK.

The AudioFormat.Builder class can be used to create instances of
 the AudioFormat format class.
 Refer to
 AudioFormat.Builder for documentation on the mechanics of the configuration and building
 of such instances. Here we describe the main concepts that the AudioFormat class
 allow you to convey in each instance, they are:

sample rate

encoding

channel masks

Closely associated with the AudioFormat is the notion of an
 audio frame, which is used throughout the documentation
 to represent the minimum size complete unit of audio data.

Sample rate

Expressed in Hz, the sample rate in an AudioFormat instance expresses the number
 of audio samples for each channel per second in the content you are playing or recording. It is
 not the sample rate
 at which content is rendered or produced. For instance a sound at a media sample rate of 8000Hz
 can be played on a device operating at a sample rate of 48000Hz; the sample rate conversion is
 automatically handled by the platform, it will not play at 6x speed.

As of API M,
 sample rates up to 192kHz are supported
 for AudioRecord and AudioTrack, with sample rate conversion
 performed as needed.
 To improve efficiency and avoid lossy conversions, it is recommended to match the sample rate
 for AudioRecord and AudioTrack to the endpoint device
 sample rate, and limit the sample rate to no more than 48kHz unless there are special
 device capabilities that warrant a higher rate.

Encoding

Audio encoding is used to describe the bit representation of audio data, which can be
 either linear PCM or compressed audio, such as AC3 or DTS.

For linear PCM, the audio encoding describes the sample size, 8 bits, 16 bits, or 32 bits,
 and the sample representation, integer or float.

 ENCODING_PCM_8BIT: The audio sample is a 8 bit unsigned integer in the
 range [0, 255], with a 128 offset for zero. This is typically stored as a Java byte in a
 byte array or ByteBuffer. Since the Java byte is signed,
 be careful with math operations and conversions as the most significant bit is inverted.

 ENCODING_PCM_16BIT: The audio sample is a 16 bit signed integer
 typically stored as a Java short in a short array, but when the short
 is stored in a ByteBuffer, it is native endian (as compared to the default Java big endian).
 The short has full range from [-32768, 32767],
 and is sometimes interpreted as fixed point Q.15 data.

 ENCODING_PCM_FLOAT: Introduced in
 API LOLLIPOP, this encoding specifies that
 the audio sample is a 32 bit IEEE single precision float. The sample can be
 manipulated as a Java float in a float array, though within a ByteBuffer
 it is stored in native endian byte order.
 The nominal range of ENCODING_PCM_FLOAT audio data is [-1.0, 1.0].
 It is implementation dependent whether the positive maximum of 1.0 is included
 in the interval. Values outside of the nominal range are clamped before
 sending to the endpoint device. Beware that
 the handling of NaN is undefined; subnormals may be treated as zero; and
 infinities are generally clamped just like other values for AudioTrack
 – try to avoid infinities because they can easily generate a NaN.

 To achieve higher audio bit depth than a signed 16 bit integer short,
 it is recommended to use ENCODING_PCM_FLOAT for audio capture, processing,
 and playback.
 Floats are efficiently manipulated by modern CPUs,
 have greater precision than 24 bit signed integers,
 and have greater dynamic range than 32 bit signed integers.
 AudioRecord as of API M and
 AudioTrack as of API LOLLIPOP
 support ENCODING_PCM_FLOAT.

For compressed audio, the encoding specifies the method of compression,
 for example ENCODING_AC3 and ENCODING_DTS. The compressed
 audio data is typically stored as bytes in
 a byte array or ByteBuffer. When a compressed audio encoding is specified
 for an AudioTrack, it creates a direct (non-mixed) track
 for output to an endpoint (such as HDMI) capable of decoding the compressed audio.
 For (most) other endpoints, which are not capable of decoding such compressed audio,
 you will need to decode the data first, typically by creating a MediaCodec.
 Alternatively, one may use MediaPlayer for playback of compressed
 audio files or streams.

When compressed audio is sent out through a direct AudioTrack,
 it need not be written in exact multiples of the audio access unit;
 this differs from MediaCodec input buffers.

Channel mask

Channel masks are used in AudioTrack and AudioRecord to describe
 the samples and their arrangement in the audio frame. They are also used in the endpoint (e.g.
 a USB audio interface, a DAC connected to headphones) to specify allowable configurations of a
 particular device.

As of API M, there are two types of channel masks:
 channel position masks and channel index masks.

Channel position masks

 Channel position masks are the original Android channel masks, and are used since API
 BASE.
 For input and output, they imply a positional nature - the location of a speaker or a microphone
 for recording or playback.

For a channel position mask, each allowed channel position corresponds to a bit in the
 channel mask. If that channel position is present in the audio frame, that bit is set,
 otherwise it is zero. The order of the bits (from lsb to msb) corresponds to the order of that
 position's sample in the audio frame.

The canonical channel position masks by channel count are as follows:

channel count	channel position mask

1	CHANNEL_OUT_MONO

2	CHANNEL_OUT_STEREO

3	CHANNEL_OUT_STEREO | CHANNEL_OUT_FRONT_CENTER

4	CHANNEL_OUT_QUAD

5	CHANNEL_OUT_QUAD | CHANNEL_OUT_FRONT_CENTER

6	CHANNEL_OUT_5POINT1

7	CHANNEL_OUT_5POINT1 | CHANNEL_OUT_BACK_CENTER

8	CHANNEL_OUT_7POINT1_SURROUND

These masks are an ORed composite of individual channel masks. For example
 CHANNEL_OUT_STEREO is composed of CHANNEL_OUT_FRONT_LEFT and
 CHANNEL_OUT_FRONT_RIGHT.

Channel index masks

 Channel index masks are introduced in API M. They allow
 the selection of a particular channel from the source or sink endpoint by number, i.e. the first
 channel, the second channel, and so forth. This avoids problems with artificially assigning
 positions to channels of an endpoint, or figuring what the ith position bit is within
 an endpoint's channel position mask etc.

Here's an example where channel index masks address this confusion: dealing with a 4 channel
 USB device. Using a position mask, and based on the channel count, this would be a
 CHANNEL_OUT_QUAD device, but really one is only interested in channel 0
 through channel 3. The USB device would then have the following individual bit channel masks:
 CHANNEL_OUT_FRONT_LEFT,
 CHANNEL_OUT_FRONT_RIGHT, CHANNEL_OUT_BACK_LEFT
 and CHANNEL_OUT_BACK_RIGHT. But which is channel 0 and which is
 channel 3?

For a channel index mask, each channel number is represented as a bit in the mask, from the
 lsb (channel 0) upwards to the msb, numerically this bit value is
 1 << channelNumber.
 A set bit indicates that channel is present in the audio frame, otherwise it is cleared.
 The order of the bits also correspond to that channel number's sample order in the audio frame.

For the previous 4 channel USB device example, the device would have a channel index mask
 0xF. Suppose we wanted to select only the first and the third channels; this would
 correspond to a channel index mask 0x5 (the first and third bits set). If an
 AudioTrack uses this channel index mask, the audio frame would consist of two
 samples, the first sample of each frame routed to channel 0, and the second sample of each frame
 routed to channel 2.
 The canonical channel index masks by channel count are given by the formula
 (1 << channelCount) - 1.

Use cases

Channel position mask for an endpoint: CHANNEL_OUT_FRONT_LEFT,
  CHANNEL_OUT_FRONT_CENTER, etc. for HDMI home theater purposes.

Channel position mask for an audio stream: Creating an AudioTrack
  to output movie content, where 5.1 multichannel output is to be written.

Channel index mask for an endpoint: USB devices for which input and output do not
  correspond to left or right speaker or microphone.

Channel index mask for an audio stream: An AudioRecord may only want the
  third and fourth audio channels of the endpoint (i.e. the second channel pair), and not care the
  about position it corresponds to, in which case the channel index mask is 0xC.
  Multichannel AudioRecord sessions should use channel index masks.

Audio Frame

For linear PCM, an audio frame consists of a set of samples captured at the same time,
 whose count and
 channel association are given by the channel mask,
 and whose sample contents are specified by the encoding.
 For example, a stereo 16 bit PCM frame consists of
 two 16 bit linear PCM samples, with a frame size of 4 bytes.
 For compressed audio, an audio frame may alternately
 refer to an access unit of compressed data bytes that is logically grouped together for
 decoding and bitstream access (e.g. MediaCodec),
 or a single byte of compressed data (e.g. AudioTrack.getBufferSizeInFrames()),
 or the linear PCM frame result from decoding the compressed data
 (e.g.AudioTrack.getPlaybackHeadPosition()),
 depending on the context where audio frame is used.

Summary

Nested Classes

      <nobr>

        class</nobr>
      AudioFormat.Builder

        Builder class for AudioFormat objects.

Constants

        int
        CHANNEL_CONFIGURATION_DEFAULT

      This constant was deprecated
      in API level 5.
    Use CHANNEL_OUT_DEFAULT or CHANNEL_IN_DEFAULT instead.

        int
        CHANNEL_CONFIGURATION_INVALID

      This constant was deprecated
      in API level 5.
    Use CHANNEL_INVALID instead.

        int
        CHANNEL_CONFIGURATION_MONO

      This constant was deprecated
      in API level 5.
    Use CHANNEL_OUT_MONO or CHANNEL_IN_MONO instead.

        int
        CHANNEL_CONFIGURATION_STEREO

      This constant was deprecated
      in API level 5.
    Use CHANNEL_OUT_STEREO or CHANNEL_IN_STEREO instead.

        int
        CHANNEL_INVALID

          Invalid audio channel mask

        int
        CHANNEL_IN_BACK

        int
        CHANNEL_IN_BACK_PROCESSED

        int
        CHANNEL_IN_DEFAULT

        int
        CHANNEL_IN_FRONT

        int
        CHANNEL_IN_FRONT_PROCESSED

        int
        CHANNEL_IN_LEFT

        int
        CHANNEL_IN_LEFT_PROCESSED

        int
        CHANNEL_IN_MONO

        int
        CHANNEL_IN_PRESSURE

        int
        CHANNEL_IN_RIGHT

        int
        CHANNEL_IN_RIGHT_PROCESSED

        int
        CHANNEL_IN_STEREO

        int
        CHANNEL_IN_VOICE_DNLINK

        int
        CHANNEL_IN_VOICE_UPLINK

        int
        CHANNEL_IN_X_AXIS

        int
        CHANNEL_IN_Y_AXIS

        int
        CHANNEL_IN_Z_AXIS

        int
        CHANNEL_OUT_5POINT1

        int
        CHANNEL_OUT_7POINT1

      This constant was deprecated
      in API level 23.
    Not the typical 7.1 surround configuration. Use CHANNEL_OUT_7POINT1_SURROUND instead.

        int
        CHANNEL_OUT_7POINT1_SURROUND

        int
        CHANNEL_OUT_BACK_CENTER

        int
        CHANNEL_OUT_BACK_LEFT

        int
        CHANNEL_OUT_BACK_RIGHT

        int
        CHANNEL_OUT_DEFAULT

          Default audio channel mask

        int
        CHANNEL_OUT_FRONT_CENTER

        int
        CHANNEL_OUT_FRONT_LEFT

        int
        CHANNEL_OUT_FRONT_LEFT_OF_CENTER

        int
        CHANNEL_OUT_FRONT_RIGHT

        int
        CHANNEL_OUT_FRONT_RIGHT_OF_CENTER

        int
        CHANNEL_OUT_LOW_FREQUENCY

        int
        CHANNEL_OUT_MONO

        int
        CHANNEL_OUT_QUAD

        int
        CHANNEL_OUT_SIDE_LEFT

        int
        CHANNEL_OUT_SIDE_RIGHT

        int
        CHANNEL_OUT_STEREO

        int
        CHANNEL_OUT_SURROUND

        int
        ENCODING_AC3

          Audio data format: AC-3 compressed

        int
        ENCODING_DEFAULT

          Default audio data format

        int
        ENCODING_DTS

          Audio data format: DTS compressed

        int
        ENCODING_DTS_HD

          Audio data format: DTS HD compressed

        int
        ENCODING_E_AC3

          Audio data format: E-AC-3 compressed

        int
        ENCODING_INVALID

          Invalid audio data format

        int
        ENCODING_PCM_16BIT

          Audio data format: PCM 16 bit per sample.

        int
        ENCODING_PCM_8BIT

          Audio data format: PCM 8 bit per sample.

        int
        ENCODING_PCM_FLOAT

          Audio data format: single-precision floating-point per sample

Public Methods

        <nobr>

            int</nobr>

        <nobr>
        getChannelCount()</nobr>

          Return the channel count.

        <nobr>

            int</nobr>

        <nobr>
        getChannelIndexMask()</nobr>

          Return the channel index mask.

        <nobr>

            int</nobr>

        <nobr>
        getChannelMask()</nobr>

          Return the channel mask.

        <nobr>

            int</nobr>

        <nobr>
        getEncoding()</nobr>

          Return the encoding.

        <nobr>

            int</nobr>

        <nobr>
        getSampleRate()</nobr>

          Return the sample rate.

        <nobr>

            String</nobr>

        <nobr>
        toString()</nobr>

          Returns a string containing a concise, human-readable description of this
 object.

  [Expand]

Inherited Methods

From class

  java.lang.Object

        <nobr>

            Object</nobr>

        <nobr>
        clone()</nobr>

          Creates and returns a copy of this Object.

        <nobr>

            boolean</nobr>

        <nobr>
        equals(Object o)</nobr>

          Compares this instance with the specified object and indicates if they
 are equal.

        <nobr>

            void</nobr>

        <nobr>
        finalize()</nobr>

          Invoked when the garbage collector has detected that this instance is no longer reachable.

        <nobr>

            final

            Class<?></nobr>

        <nobr>
        getClass()</nobr>

          Returns the unique instance of Class that represents this
 object's class.

        <nobr>

            int</nobr>

        <nobr>
        hashCode()</nobr>

          Returns an integer hash code for this object.

        <nobr>

            final

            void</nobr>

        <nobr>
        notify()</nobr>

          Causes a thread which is waiting on this object's monitor (by means of
 calling one of the wait() methods) to be woken up.

        <nobr>

            final

            void</nobr>

        <nobr>
        notifyAll()</nobr>

          Causes all threads which are waiting on this object's monitor (by means
 of calling one of the wait() methods) to be woken up.

        <nobr>

            String</nobr>

        <nobr>
        toString()</nobr>

          Returns a string containing a concise, human-readable description of this
 object.

        <nobr>

            final

            void</nobr>

        <nobr>
        wait()</nobr>

          Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

        <nobr>

            final

            void</nobr>

        <nobr>
        wait(long millis, int nanos)</nobr>

          Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
 specified timeout expires.

        <nobr>

            final

            void</nobr>

        <nobr>
        wait(long millis)</nobr>

          Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
 specified timeout expires.

Constants

        public
        static
        final
        int

        CHANNEL_CONFIGURATION_DEFAULT

  Added in API level 3

      This constant was deprecated
      in API level 5.

    Use CHANNEL_OUT_DEFAULT or CHANNEL_IN_DEFAULT instead.

        Constant Value:

                1
                (0x00000001)

        public
        static
        final
        int

        CHANNEL_CONFIGURATION_INVALID

  Added in API level 3

      This constant was deprecated
      in API level 5.

    Use CHANNEL_INVALID instead.

        Constant Value:

                0
                (0x00000000)

        public
        static
        final
        int

        CHANNEL_CONFIGURATION_MONO

  Added in API level 3

      This constant was deprecated
      in API level 5.

    Use CHANNEL_OUT_MONO or CHANNEL_IN_MONO instead.

        Constant Value:

                2
                (0x00000002)

        public
        static
        final
        int

        CHANNEL_CONFIGURATION_STEREO

  Added in API level 3

      This constant was deprecated
      in API level 5.

    Use CHANNEL_OUT_STEREO or CHANNEL_IN_STEREO instead.

        Constant Value:

                3
                (0x00000003)

        public
        static
        final
        int

        CHANNEL_INVALID

  Added in API level 5

Invalid audio channel mask

        Constant Value:

                0
                (0x00000000)

        public
        static
        final
        int

        CHANNEL_IN_BACK

  Added in API level 5

        Constant Value:

                32
                (0x00000020)

        public
        static
        final
        int

        CHANNEL_IN_BACK_PROCESSED

  Added in API level 5

        Constant Value:

                512
                (0x00000200)

        public
        static
        final
        int

        CHANNEL_IN_DEFAULT

  Added in API level 5

        Constant Value:

                1
                (0x00000001)

        public
        static
        final
        int

        CHANNEL_IN_FRONT

  Added in API level 5

        Constant Value:

                16
                (0x00000010)

        public
        static
        final
        int

        CHANNEL_IN_FRONT_PROCESSED

  Added in API level 5

        Constant Value:

                256
                (0x00000100)

        public
        static
        final
        int

        CHANNEL_IN_LEFT

  Added in API level 5

        Constant Value:

                4
                (0x00000004)

        public
        static
        final
        int

        CHANNEL_IN_LEFT_PROCESSED

  Added in API level 5

        Constant Value:

                64
                (0x00000040)

        public
        static
        final
        int

        CHANNEL_IN_MONO

  Added in API level 5

        Constant Value:

                16
                (0x00000010)

        public
        static
        final
        int

        CHANNEL_IN_PRESSURE

  Added in API level 5

        Constant Value:

                1024
                (0x00000400)

        public
        static
        final
        int

        CHANNEL_IN_RIGHT

  Added in API level 5

        Constant Value:

                8
                (0x00000008)

        public
        static
        final
        int

        CHANNEL_IN_RIGHT_PROCESSED

  Added in API level 5

        Constant Value:

                128
                (0x00000080)

        public
        static
        final
        int

        CHANNEL_IN_STEREO

  Added in API level 5

        Constant Value:

                12
                (0x0000000c)

        public
        static
        final
        int

        CHANNEL_IN_VOICE_DNLINK

  Added in API level 5

        Constant Value:

                32768
                (0x00008000)

        public
        static
        final
        int

        CHANNEL_IN_VOICE_UPLINK

  Added in API level 5

        Constant Value:

                16384
                (0x00004000)

        public
        static
        final
        int

        CHANNEL_IN_X_AXIS

  Added in API level 5

        Constant Value:

                2048
                (0x00000800)

        public
        static
        final
        int

        CHANNEL_IN_Y_AXIS

  Added in API level 5

        Constant Value:

                4096
                (0x00001000)

        public
        static
        final
        int

        CHANNEL_IN_Z_AXIS

  Added in API level 5

        Constant Value:

                8192
                (0x00002000)

        public
        static
        final
        int

        CHANNEL_OUT_5POINT1

  Added in API level 5

        Constant Value:

                252
                (0x000000fc)

        public
        static
        final
        int

        CHANNEL_OUT_7POINT1

  Added in API level 5

      This constant was deprecated
      in API level 23.

    Not the typical 7.1 surround configuration. Use CHANNEL_OUT_7POINT1_SURROUND instead.

        Constant Value:

                1020
                (0x000003fc)

        public
        static
        final
        int

        CHANNEL_OUT_7POINT1_SURROUND

  Added in API level 23

        Constant Value:

                6396
                (0x000018fc)

        public
        static
        final
        int

        CHANNEL_OUT_BACK_CENTER

  Added in API level 5

        Constant Value:

                1024
                (0x00000400)

        public
        static
        final
        int

        CHANNEL_OUT_BACK_LEFT

  Added in API level 5

        Constant Value:

                64
                (0x00000040)

        public
        static
        final
        int

        CHANNEL_OUT_BACK_RIGHT

  Added in API level 5

        Constant Value:

                128
                (0x00000080)

        public
        static
        final
        int

        CHANNEL_OUT_DEFAULT

  Added in API level 5

Default audio channel mask

        Constant Value:

                1
                (0x00000001)

        public
        static
        final
        int

        CHANNEL_OUT_FRONT_CENTER

  Added in API level 5

        Constant Value:

                16
                (0x00000010)

        public
        static
        final
        int

        CHANNEL_OUT_FRONT_LEFT

  Added in API level 5

        Constant Value:

                4
                (0x00000004)

        public
        static
        final
        int

        CHANNEL_OUT_FRONT_LEFT_OF_CENTER

  Added in API level 5

        Constant Value:

                256
                (0x00000100)

        public
        static
        final
        int

        CHANNEL_OUT_FRONT_RIGHT

  Added in API level 5

        Constant Value:

                8
                (0x00000008)

        public
        static
        final
        int

        CHANNEL_OUT_FRONT_RIGHT_OF_CENTER

  Added in API level 5

        Constant Value:

                512
                (0x00000200)

        public
        static
        final
        int

        CHANNEL_OUT_LOW_FREQUENCY

  Added in API level 5

        Constant Value:

                32
                (0x00000020)

        public
        static
        final
        int

        CHANNEL_OUT_MONO

  Added in API level 5

        Constant Value:

                4
                (0x00000004)

        public
        static
        final
        int

        CHANNEL_OUT_QUAD

  Added in API level 5

        Constant Value:

                204
                (0x000000cc)

        public
        static
        final
        int

        CHANNEL_OUT_SIDE_LEFT

  Added in API level 21

        Constant Value:

                2048
                (0x00000800)

        public
        static
        final
        int

        CHANNEL_OUT_SIDE_RIGHT

  Added in API level 21

        Constant Value:

                4096
                (0x00001000)

        public
        static
        final
        int

        CHANNEL_OUT_STEREO

  Added in API level 5

        Constant Value:

                12
                (0x0000000c)

        public
        static
        final
        int

        CHANNEL_OUT_SURROUND

  Added in API level 5

        Constant Value:

                1052
                (0x0000041c)

        public
        static
        final
        int

        ENCODING_AC3

  Added in API level 21

Audio data format: AC-3 compressed

        Constant Value:

                5
                (0x00000005)

        public
        static
        final
        int

        ENCODING_DEFAULT

  Added in API level 3

Default audio data format

        Constant Value:

                1
                (0x00000001)

        public
        static
        final
        int

        ENCODING_DTS

  Added in API level 23

Audio data format: DTS compressed

        Constant Value:

                7
                (0x00000007)

        public
        static
        final
        int

        ENCODING_DTS_HD

  Added in API level 23

Audio data format: DTS HD compressed

        Constant Value:

                8
                (0x00000008)

        public
        static
        final
        int

        ENCODING_E_AC3

  Added in API level 21

Audio data format: E-AC-3 compressed

        Constant Value:

                6
                (0x00000006)

        public
        static
        final
        int

        ENCODING_INVALID

  Added in API level 3

Invalid audio data format

        Constant Value:

                0
                (0x00000000)

        public
        static
        final
        int

        ENCODING_PCM_16BIT

  Added in API level 3

Audio data format: PCM 16 bit per sample. Guaranteed to be supported by devices.

        Constant Value:

                2
                (0x00000002)

        public
        static
        final
        int

        ENCODING_PCM_8BIT

  Added in API level 3

Audio data format: PCM 8 bit per sample. Not guaranteed to be supported by devices.

        Constant Value:

                3
                (0x00000003)

        public
        static
        final
        int

        ENCODING_PCM_FLOAT

  Added in API level 21

Audio data format: single-precision floating-point per sample

        Constant Value:

                4
                (0x00000004)

Public Methods

        public

        int

      getChannelCount
      ()

  Added in API level 23

Return the channel count.

Returns

the channel count derived from the channel position mask or the channel index mask.
 Zero is returned if both the channel position mask and the channel index mask are not set.

        public

        int

      getChannelIndexMask
      ()

  Added in API level 23

Return the channel index mask.
 See the section on channel masks for more information about
 the difference between index-based masks, and position-based masks (as returned
 by getChannelMask()).

Returns

one of the values that can be set in setChannelIndexMask(int) or
 CHANNEL_INVALID if not set or an invalid mask was used.

        public

        int

      getChannelMask
      ()

  Added in API level 21

Return the channel mask.
 See the section on channel masks for more information about
 the difference between index-based masks(as returned by getChannelIndexMask()) and
 the position-based mask returned by this function.

Returns

one of the values that can be set in setChannelMask(int) or
 CHANNEL_INVALID if not set.

        public

        int

      getEncoding
      ()

  Added in API level 21

Return the encoding.
 See the section on encodings for more information about the different
 types of supported audio encoding.

Returns

one of the values that can be set in setEncoding(int) or
 ENCODING_INVALID if not set.

        public

        int

      getSampleRate
      ()

  Added in API level 21

Return the sample rate.

Returns

one of the values that can be set in setSampleRate(int) or
 0 if not set.

        public

        String

      toString
      ()

  Added in API level 3

Returns a string containing a concise, human-readable description of this
 object. Subclasses are encouraged to override this method and provide an
 implementation that takes into account the object's type and data. The
 default implementation is equivalent to the following expression:

   getClass().getName() + '@' + Integer.toHexString(hashCode())

See Writing a useful
 toString method
 if you intend implementing your own toString method.

Returns

a printable representation of this object.

        Get news & tips

          Blog
          Support

  Except as noted, this content is licensed under Apache 2.0.
  For details and restrictions, see the
  Content License.

    Android 6.0 r1 —

      About Android
      Auto
      TV
      Wear
      Legal

        <select name="language" onchange="changeLangPref(this.value, true)">
          <option value="en" selected="selected">English</option>
          <option value="es">Español</option>
          <option value="ja">日本語</option>
          <option value="ko">한국어</option>
          <option value="pt-br">Português Brasileiro</option>
          <option value="ru">Русский</option>
          <option value="zh-cn">中文(简体)</option>
          <option value="zh-tw">中文(繁體)</option>
        </select>

        <button class="dac-modal-header-close" data-modal-toggle></button>

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

          <form action="https://docs.google.com/forms/d/1QgnkzbEJIDu9lMEea0mxqWrXUJu0oBCLD7ar23V0Yys/formResponse" class="dac-form" method="post" target="dac-newsletter-iframe">

              <fieldset class="dac-form-fieldset">

                      Full name
                      <input type="text" class="dac-form-input" name="entry.1357890476" id="newsletter-full-name" required>
                      *

                      Email address
                      <input type="email" class="dac-form-input" name="entry.472100832" id="newsletter-email" required>
                      *

                      Company / developer name
                      <input type="text" class="dac-form-input" name="entry.1664780309" id="newsletter-company">

                      One of your Play Store app URLs
                      <input type="url" class="dac-form-input" name="entry.47013838" id="newsletter-play-store" required>
                      *

              </fieldset>
              <fieldset class="dac-form-fieldset">

                    <legend class="dac-form-legend">Which best describes your business:*
                    </legend>

                      <input type="radio" value="Apps" class="dac-form-radio" name="entry.1796324055" id="newsletter-business-type-app" required>

                      Apps

                      <input type="radio" value="Games" class="dac-form-radio" name="entry.1796324055" id="newsletter-business-type-games" required>

                      Games

                      <input type="radio" value="Apps and Games" class="dac-form-radio" name="entry.1796324055" id="newsletter-business-type-appsgames" required>

                      Apps & Games

                          <input type="checkbox" class="dac-form-checkbox" name="entry.732309842" id="newsletter-add" required value="Add me to the mailing list for the monthly newsletter and occasional emails about development and Google Play opportunities.">

                          Add me to the mailing list for the monthly newsletter and occasional emails about development and Google Play opportunities.*

                          <input type="checkbox" class="dac-form-checkbox" name="entry.2045036090" id="newsletter-terms" required value="I acknowledge that the information provided in this form will be subject to Google's privacy policy (https://www.google.com/policies/privacy/).">

                          I acknowledge that the information provided in this form will be subject to Google's privacy policy.*

              </fieldset>

              <button type="submit" value="Submit" class="dac-fab dac-primary dac-large dac-modal-action"></button>

          </form>

              You have successfully signed up for the latest Android developer news and tips.


text:
"""
File: test_delete_preset.py
Date: 2015/06/29 14:44:40
"""
import os
import sys
import unittest
import json
import time
import media_config
import re
import mediaBase
import random

_NOW_PATH = os.path.dirname(os.path.abspath(__file__)) + '/'
_COMMON_PATH = _NOW_PATH + '../../../'
sys.path.insert(0, _COMMON_PATH)

from baidubce.services.media import media_client
from baidubce.exception import BceHttpClientError
from baidubce.exception import BceServerError
from baidubce.exception import BceClientError
import nose

class TestDeletePreset(mediaBase.MediaBase):
    """test delete preset"""
    def __init__(self):
        """construction """
        mediaBase.MediaBase.__init__(self)
        self.pre = self.prefix + 'deletepreset'
        self.preset_name = self.pre
        self.container = 'mp4'
        self.client = media_client.MediaClient(media_config.config)

    def setUp(self):
        """create env"""
        resp = self.client.create_preset(self.preset_name, self.container, True)
        nose.tools.assert_is_not_none(resp)

    def tearDown(self):
        """clear env"""
        result = self.client.list_presets()
        for each_val in result.presets:
            preset_name = each_val.preset_name
            if(preset_name.startswith(self.pre)):
                resp = self.client.delete_preset(preset_name)
                nose.tools.assert_is_not_none(resp)

    def test_delete_preset_exist(self):
        """delete exist preset"""
        resp = self.client.delete_preset(self.preset_name)
        nose.tools.assert_is_not_none(resp)

    def test_delete_preset_repeated(self):
        """delete preset repeated"""
        resp = self.client.delete_preset(self.preset_name)
        nose.tools.assert_is_not_none(resp)
        try:
            resp = self.client.delete_preset(self.preset_name)
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith('The requested preset does not exist')
            else:
                assert True == False, 'not throw BceServerError'

    def test_delete_preset_not_exist(self):
        """delete preset not exist"""
        try:
            resp = self.client.delete_preset('not_exist_preset')
        except BceHttpClientError as e:
            if isinstance(e.last_error, BceServerError):
                assert e.last_error.message.startswith('The requested preset does not exist')
            else:
                assert True == False, 'not throw BceServerError'

    def test_delete_preset_name_empty(self):
        """delete preset with name empty"""
        with nose.tools.assert_raises_regexp(BceClientError,
                'preset_name can\'t be empty string'):
            resp = self.client.delete_preset('')

    def test_delete_preset_name_none(self):
        """delete preset with name none"""
        try:
            resp = self.client.delete_preset(None)
        except ValueError as e:
            assert e.message.startswith('arg "preset_name" should not be None')


text:
/* tslint:disable */
/* eslint-disable */
// @generated
// This file was automatically generated and should not be edited.

// ====================================================
// GraphQL query operation: AdminViewsProviderQuery
// ====================================================

export interface AdminViewsProviderQuery_site_siteViews_search {
  __typename: "SiteSearchPage";
  type: string;
}

export interface AdminViewsProviderQuery_site_siteViews {
  __typename: "SiteView";
  name: string | null;
  url: string | null;
  id: number;
  search: AdminViewsProviderQuery_site_siteViews_search;
}

export interface AdminViewsProviderQuery_site {
  __typename: "Site";
  id: number;
  hideDonation: boolean | null;
  siteViews: AdminViewsProviderQuery_site_siteViews[];
}

export interface AdminViewsProviderQuery {
  /**
   * If id is missing, returns current site. If id == 0, returns default site
   */
  site: AdminViewsProviderQuery_site | null;
}

export interface AdminViewsProviderQueryVariables {
  id?: number | null;
}


text:
package org.innovateuk.ifs.competition.builder;

import org.innovateuk.ifs.BaseBuilder;
import org.innovateuk.ifs.competition.domain.Competition;
import org.innovateuk.ifs.competition.domain.CompetitionType;

import java.util.List;
import java.util.function.BiConsumer;

import static java.util.Collections.emptyList;
import static org.innovateuk.ifs.base.amend.BaseBuilderAmendFunctions.*;

public class CompetitionTypeBuilder extends BaseBuilder<CompetitionType, CompetitionTypeBuilder> {

    private CompetitionTypeBuilder(List<BiConsumer<Integer, CompetitionType>> newMultiActions) {
        super(newMultiActions);
    }

    public static CompetitionTypeBuilder newCompetitionType() {
        return new CompetitionTypeBuilder(emptyList()).with(uniqueIds()).with(idBasedNames("CompetitionType "));
    }

    public CompetitionTypeBuilder withCompetitions(List<Competition> competitions) {
        return with(competitionType -> competitionType.setCompetitions(competitions));
    }

    public CompetitionTypeBuilder withName(String name) {
        return with(competitionType -> setField("name", name, competitionType));
    }

    @Override
    protected CompetitionTypeBuilder createNewBuilderWithActions(List<BiConsumer<Integer, CompetitionType>> actions) {
        return new CompetitionTypeBuilder(actions);
    }

    @Override
    protected CompetitionType createInitial() {
        return new CompetitionType();
    }

    public CompetitionTypeBuilder withId(Long... ids) {
        return withArray((id, object) -> setField("id", id, object), ids);
    }

}


text:
package mock

import (
	"crypto"
	"crypto/x509"
	"sync"

	"istio.io/istio/security/pkg/pki/util"
)

// FakeKeyCertBundle is a mocked KeyCertBundle for testing.
type FakeKeyCertBundle struct {
	CertBytes       []byte
	Cert            *x509.Certificate
	PrivKeyBytes    []byte
	PrivKey         *crypto.PrivateKey
	CertChainBytes  []byte
	RootCertBytes   []byte
	VerificationErr error
	CertOptionsErr  error
	mutex           sync.Mutex
}

// GetAllPem returns all key/cert PEMs in KeyCertBundle together. Getting all values together avoids inconsistency.
func (b *FakeKeyCertBundle) GetAllPem() (certBytes, privKeyBytes, certChainBytes, rootCertBytes []byte) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.CertBytes, b.PrivKeyBytes, b.CertChainBytes, b.RootCertBytes
}

// GetAll returns all key/cert in KeyCertBundle together. Getting all values together avoids inconsistency.
func (b *FakeKeyCertBundle) GetAll() (cert *x509.Certificate, privKey *crypto.PrivateKey, certChainBytes,
	rootCertBytes []byte) {
	b.mutex.Lock()
	defer b.mutex.Unlock()
	return b.Cert, b.PrivKey, b.CertChainBytes, b.RootCertBytes
}

// VerifyAndSetAll returns VerificationErr if it is not nil. Otherwise, it returns all the key/certs in the bundle.
func (b *FakeKeyCertBundle) VerifyAndSetAll(certBytes, privKeyBytes, certChainBytes, rootCertBytes []byte) error {
	if b.VerificationErr != nil {
		return b.VerificationErr
	}
	b.mutex.Lock()
	defer b.mutex.Unlock()
	b.CertBytes = certBytes
	b.PrivKeyBytes = privKeyBytes
	b.CertChainBytes = certChainBytes
	b.RootCertBytes = rootCertBytes
	return nil
}

// GetCertChainPem returns CertChainBytes.
func (b *FakeKeyCertBundle) GetCertChainPem() []byte {
	return b.CertChainBytes
}

// GetRootCertPem returns RootCertBytes.
func (b *FakeKeyCertBundle) GetRootCertPem() []byte {
	return b.RootCertBytes
}

// CertOptions returns CertOptionsErr if it is not nil. Otherwise it returns an empty CertOptions.
func (b *FakeKeyCertBundle) CertOptions() (*util.CertOptions, error) {
	if b.CertOptionsErr != nil {
		return nil, b.CertOptionsErr
	}
	return &util.CertOptions{}, nil
}


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Code Coverage for /var/www/zf2napratica/module/Admin/view/admin/user/save.php</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/bootstrap-responsive.min.css" rel="stylesheet">
  <link href="css/style.css" rel="stylesheet">

/var/www/zf2napratica/module/Admin /

view /

admin /

user /

save.php

Code Coverage

Classes and Traits

Functions and Methods

Lines

      Total

      CRAP

0.00%

0 / 2

1
	<?php

2
	echo $this->form()->openTag($form);

3
	echo $this->formCollection($form);

Legend

     Executed
     Not Executed
     Dead Code

     Generated by PHP_CodeCoverage 1.2.13 using PHP 5.4.4-14+deb7u5 and PHPUnit 3.7.27 at Mon Nov 18 13:23:33 BRST 2013.


text:
import collections

from neutron_lib.api.definitions import expose_l3_conntrack_helper as exposedef
from neutron_lib.api.definitions import l3
from neutron_lib.api.definitions import l3_conntrack_helper as apidef
from neutron_lib.callbacks import registry
from neutron_lib.db import api as db_api
from neutron_lib.db import resource_extend
from neutron_lib import exceptions as lib_exc
from neutron_lib.exceptions import l3 as lib_l3_exc
from neutron_lib.objects import exceptions as obj_exc
from neutron_lib.plugins import constants
from neutron_lib.plugins import directory
from oslo_config import cfg
from oslo_db import exception as oslo_db_exc

from neutron._i18n import _
from neutron.api.rpc.callbacks import events as rpc_events
from neutron.api.rpc.handlers import resources_rpc
from neutron.db import db_base_plugin_common
from neutron.extensions import l3_conntrack_helper
from neutron.objects import base as base_obj
from neutron.objects import conntrack_helper as cth
from neutron.objects import router
from neutron.services.conntrack_helper.common import exceptions as cth_exc

@resource_extend.has_resource_extenders
@registry.has_registry_receivers
class Plugin(l3_conntrack_helper.ConntrackHelperPluginBase):
    """Implementation of the Neutron Conntrack Helper Service Plugin.

    This class implements a Conntrack Helper plugin.
    """

    required_service_plugins = [l3.ROUTER]

    supported_extension_aliases = [apidef.ALIAS, exposedef.ALIAS]

    __native_pagination_support = True
    __native_sorting_support = True
    __filter_validation_support = True

    def __init__(self):
        super(Plugin, self).__init__()
        self.push_api = resources_rpc.ResourcesPushRpcApi()
        self.l3_plugin = directory.get_plugin(constants.L3)
        self.core_plugin = directory.get_plugin()

        # Option allowed_conntrack_helpers is a list of key, value pairs.
        # The list can contain same key (conntrack helper module) multiple
        # times with a different value (protocol). Merge to a dictonary
        # with key (conntrack helper) and values (protocols) as a list.
        self.constraints = collections.defaultdict(list)
        for x in cfg.CONF.allowed_conntrack_helpers:
            self.constraints[next(iter(x.keys()))].append(
                next(iter(x.values())))

    @staticmethod
    @resource_extend.extends([l3.ROUTERS])
    def _extend_router_dict(result_dict, db):
        fields = [apidef.PROTOCOL, apidef.PORT, apidef.HELPER]
        result_dict[apidef.COLLECTION_NAME] = []
        if db.conntrack_helpers:
            conntack_helper_result = []
            for conntack_helper in db.conntrack_helpers:
                cth_dict = cth.ConntrackHelper.modify_fields_from_db(
                    conntack_helper)
                for key in list(cth_dict.keys()):
                    if key not in fields:
                        cth_dict.pop(key)
                conntack_helper_result.append(cth_dict)
            result_dict[apidef.COLLECTION_NAME] = conntack_helper_result
        return result_dict

    def get_router(self, context, router_id, fields=None):
        router_obj = router.Router.get_object(context, id=router_id)
        if not router_obj:
            raise lib_l3_exc.RouterNotFound(router_id=router_id)
        return router_obj

    def _find_existing_conntrack_helper(self, context, router_id,
                                        conntrack_helper):
        # Because the session had been flushed by NeutronDbObjectDuplicateEntry
        # so if we want to use the context to get another db queries, we need
        # to rollback first.
        context.session.rollback()
        param = {'router_id': router_id,
                 'protocol': conntrack_helper['protocol'],
                 'port': conntrack_helper['port'],
                 'helper': conntrack_helper['helper']}
        objs = cth.ConntrackHelper.get_objects(context, **param)
        if objs:
            return (objs[0], param)

    def _get_conntrack_helper(self, context, id):
        cth_obj = cth.ConntrackHelper.get_object(context, id=id)
        if not cth_obj:
            raise cth_exc.ConntrackHelperNotFound(id=id)
        return cth_obj

    def _check_conntrack_helper_constraints(self, cth_obj):
        if cth_obj.helper not in self.constraints:
            raise cth_exc.ConntrackHelperNotAllowed(helper=cth_obj.helper)
        if cth_obj.protocol not in self.constraints[cth_obj.helper]:
            raise cth_exc.InvalidProtocolForHelper(
                helper=cth_obj.helper, protocol=cth_obj.protocol,
                supported_protocols=', '.join(
                    self.constraints[cth_obj.helper]))

    @db_base_plugin_common.convert_result_to_dict
    def create_router_conntrack_helper(self, context, router_id,
                                       conntrack_helper):
        conntrack_helper = conntrack_helper.get(apidef.RESOURCE_NAME)
        conntrack_helper['router_id'] = router_id
        cth_obj = cth.ConntrackHelper(context, **conntrack_helper)
        self._check_conntrack_helper_constraints(cth_obj)
        try:
            with db_api.CONTEXT_WRITER.using(context):
                # If this get_router does not raise an exception, a router
                # with router_id exists.
                self.get_router(context, router_id)
                cth_obj.create()
        except obj_exc.NeutronDbObjectDuplicateEntry:
            (__, conflict_params) = self._find_existing_conntrack_helper(
                context, router_id, cth_obj.to_dict())
            message = _("A duplicate conntrack helper entry with same "
                        "attributes already exists, conflicting values "
                        "are %s") % conflict_params
            raise lib_exc.BadRequest(resource=apidef.RESOURCE_NAME,
                                     msg=message)
        self.push_api.push(context, [cth_obj], rpc_events.CREATED)
        return cth_obj

    @db_base_plugin_common.convert_result_to_dict
    def update_router_conntrack_helper(self, context, id, router_id,
                                       conntrack_helper):
        conntrack_helper = conntrack_helper.get(apidef.RESOURCE_NAME)
        try:
            with db_api.CONTEXT_WRITER.using(context):
                cth_obj = self._get_conntrack_helper(context, id)
                cth_obj.update_fields(conntrack_helper, reset_changes=True)
                self._check_conntrack_helper_constraints(cth_obj)
                cth_obj.update()
        except oslo_db_exc.DBDuplicateEntry:
            (__, conflict_params) = self._find_existing_conntrack_helper(
                context, cth_obj.router_id, cth_obj.to_dict())
            message = _("A duplicate conntrack helper entry with same "
                        "attributes already exists, conflicting values "
                        "are %s") % conflict_params
            raise lib_exc.BadRequest(resource=apidef.RESOURCE_NAME,
                                     msg=message)
        self.push_api.push(context, [cth_obj], rpc_events.UPDATED)
        return cth_obj

    @db_base_plugin_common.make_result_with_fields
    @db_base_plugin_common.convert_result_to_dict
    def get_router_conntrack_helper(self, context, id, router_id, fields=None):
        return self._get_conntrack_helper(context, id)

    @db_base_plugin_common.make_result_with_fields
    @db_base_plugin_common.convert_result_to_dict
    def get_router_conntrack_helpers(self, context, router_id=None,
                                     filters=None, fields=None, sorts=None,
                                     limit=None, marker=None,
                                     page_reverse=False):
        filters = filters or {}
        pager = base_obj.Pager(sorts, limit, page_reverse, marker)
        return cth.ConntrackHelper.get_objects(context, _pager=pager,
                                               router_id=router_id, **filters)

    def delete_router_conntrack_helper(self, context, id, router_id):
        cth_obj = self._get_conntrack_helper(context, id)
        with db_api.CONTEXT_WRITER.using(context):
            cth_obj.delete()
        self.push_api.push(context, [cth_obj], rpc_events.DELETED)