# OpalRawMediaStream Class Reference

`#include <mediastrm.h>`

Inheritance diagram for OpalRawMediaStream:

[legend]
Collaboration diagram for OpalRawMediaStream:
[legend]

## Public Member Functions

Overrides of OpalMediaStream class
virtual PBoolean | ReadData (BYTE *data, PINDEX size, PINDEX &length)
virtual PBoolean | WriteData (const BYTE *data, PINDEX length, PINDEX &written)
PChannel * | GetChannel ()
bool | SetChannel (PChannel *channel, bool autoDelete=true)
virtual unsigned | GetAverageSignalLevel ()

## Protected Member Functions

virtual void | InternalClose ()
void | CollectAverage (const BYTE *buffer, PINDEX size)
Construction
| OpalRawMediaStream (OpalConnection &conn, const OpalMediaFormat &mediaFormat, unsigned sessionID, bool isSource, PChannel *channel, bool autoDelete)
| ~OpalRawMediaStream ()

## Protected Attributes

PChannel * | m_channel
bool | m_autoDelete
PMutex | m_channelMutex
PBYTEArray | m_silence
PUInt64 | m_averageSignalSum
unsigned | m_averageSignalSamples
PMutex | m_averagingMutex

## Detailed Description

This class describes a media stream that transfers PCM-16 data to/from a PChannel.

## Constructor & Destructor Documentation

OpalRawMediaStream::OpalRawMediaStream | ( | OpalConnection & | conn,
|  | const OpalMediaFormat & | mediaFormat,
|  | unsigned | sessionID,
|  | bool | isSource,
|  | PChannel * | channel,
|  | bool | autoDelete |
| ) |  |  | `[protected]`

Construct a new media stream for channel.

Parameters:

  conn | Connection that owns the stream
  mediaFormat | Media format for stream
  sessionID | Session number for stream
  isSource | Is a source stream
  channel | I/O channel to stream to/from
  autoDelete | Automatically delete channel

OpalRawMediaStream::~OpalRawMediaStream | ( |  | ) | `[protected]`

Delete attached channel if autoDelete enabled.

## Member Function Documentation

void OpalRawMediaStream::CollectAverage | ( | const BYTE * | buffer,
|  | PINDEX | size |
| ) |  |  | `[protected]`

virtual unsigned OpalRawMediaStream::GetAverageSignalLevel | ( |  | ) | `[virtual]`

Get average signal level in last frame.

PChannel* OpalRawMediaStream::GetChannel | ( |  | ) | `[inline]`

Return the associated PChannel

virtual void OpalRawMediaStream::InternalClose | ( |  | ) | `[protected, virtual]`

Close any internal components of the stream. This should be used in preference to overriding the Close() function as it is guaranteed to be called exactly once and avoids race conditions in the shut down sequence of a media stream.

Implements OpalMediaStream.

Reimplemented in OpalIVRMediaStream.

virtual PBoolean OpalRawMediaStream::ReadData | ( | BYTE * | data,
|  | PINDEX | size,
|  | PINDEX & | length |
| ) |  |  | `[virtual]`

Read raw media data from the source media stream. The default behaviour reads from the PChannel object.

Parameters:

  data | Data buffer to read to
  size | Size of buffer
  length | Length of data actually read

Reimplemented from OpalMediaStream.

Reimplemented in OpalFileMediaStream.

bool OpalRawMediaStream::SetChannel | ( | PChannel * | channel,
|  | bool | autoDelete = `true` |
| ) |  |  |

Set a new channel for raw PCM stream.

Parameters:

  channel | New channel
  autoDelete | Auto delete channel on exit or replacement

virtual PBoolean OpalRawMediaStream::WriteData | ( | const BYTE * | data,
|  | PINDEX | length,
|  | PINDEX & | written |
| ) |  |  | `[virtual]`

Write raw media data to the sink media stream. The default behaviour writes to the PChannel object.

Parameters:

  data | Data to write
  length | Length of data to read.
  written | Length of data actually written

Reimplemented from OpalMediaStream.

Reimplemented in OpalFileMediaStream.

## Field Documentation

bool OpalRawMediaStream::m_autoDelete `[protected]`

unsigned OpalRawMediaStream::m_averageSignalSamples `[protected]`

PUInt64 OpalRawMediaStream::m_averageSignalSum `[protected]`

PMutex OpalRawMediaStream::m_averagingMutex `[protected]`

PChannel* OpalRawMediaStream::m_channel `[protected]`

PMutex OpalRawMediaStream::m_channelMutex `[protected]`

PBYTEArray OpalRawMediaStream::m_silence `[protected]`

The documentation for this class was generated from the following file:

- mediastrm.h