TOXYGEN
 All Classes Functions
Public Member Functions | Public Attributes | List of all members
toxygen.toxav.ToxAV Class Reference

Public Member Functions

def __init__
 
def __del__
 
def get_tox_pointer
 
def iteration_interval
 
def iterate
 
def call
 
def callback_call
 
def answer
 
def callback_call_state
 
def call_control
 
def audio_send_frame
 
def video_send_frame
 
def callback_audio_receive_frame
 
def callback_video_receive_frame
 

Public Attributes

 libtoxav
 
 call_state_cb
 
 audio_receive_frame_cb
 
 video_receive_frame_cb
 
 call_cb
 

Detailed Description

The ToxAV instance type. Each ToxAV instance can be bound to only one Tox instance, and Tox instance can have only
one ToxAV instance. One must make sure to close ToxAV instance prior closing Tox instance otherwise undefined
behaviour occurs. Upon closing of ToxAV instance, all active calls will be forcibly terminated without notifying
peers.

Constructor & Destructor Documentation

def toxygen.toxav.ToxAV.__init__ (   self,
  tox_pointer 
)
Start new A/V session. There can only be only one session per Tox instance.

:param tox_pointer: pointer to Tox instance
def toxygen.toxav.ToxAV.__del__ (   self)
Releases all resources associated with the A/V session.

If any calls were ongoing, these will be forcibly terminated without notifying peers. After calling this
function, no other functions may be called and the av pointer becomes invalid.

Member Function Documentation

def toxygen.toxav.ToxAV.answer (   self,
  friend_number,
  audio_bit_rate,
  video_bit_rate 
)
Accept an incoming call.

If answering fails for any reason, the call will still be pending and it is possible to try and answer it later.
Audio and video receiving are both enabled by default.

:param friend_number: The friend number of the friend that is calling.
:param audio_bit_rate: Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
:param video_bit_rate: Video bit rate in Kb/sec. Set this to 0 to disable video sending.
:return: True on success.
def toxygen.toxav.ToxAV.audio_send_frame (   self,
  friend_number,
  pcm,
  sample_count,
  channels,
  sampling_rate 
)
Send an audio frame to a friend.

The expected format of the PCM data is: [s1c1][s1c2][...][s2c1][s2c2][...]...
Meaning: sample 1 for channel 1, sample 1 for channel 2, ...
For mono audio, this has no meaning, every sample is subsequent. For stereo, this means the expected format is
LRLRLR... with samples for left and right alternating.

:param friend_number: The friend number of the friend to which to send an audio frame.
:param pcm: An array of audio samples. The size of this array must be sample_count * channels.
:param sample_count: Number of samples in this frame. Valid numbers here are
((sample rate) * (audio length) / 1000), where audio length can be 2.5, 5, 10, 20, 40 or 60 milliseconds.
:param channels: Number of audio channels. Sulpported values are 1 and 2.
:param sampling_rate: Audio sampling rate used in this frame. Valid sampling rates are 8000, 12000, 16000,
24000, or 48000.
def toxygen.toxav.ToxAV.call (   self,
  friend_number,
  audio_bit_rate,
  video_bit_rate 
)
Call a friend. This will start ringing the friend.

It is the client's responsibility to stop ringing after a certain timeout, if such behaviour is desired. If the
client does not stop ringing, the library will not stop until the friend is disconnected. Audio and video
receiving are both enabled by default.

:param friend_number: The friend number of the friend that should be called.
:param audio_bit_rate: Audio bit rate in Kb/sec. Set this to 0 to disable audio sending.
:param video_bit_rate: Video bit rate in Kb/sec. Set this to 0 to disable video sending.
:return: True on success.
def toxygen.toxav.ToxAV.call_control (   self,
  friend_number,
  control 
)
Sends a call control command to a friend.

:param friend_number: The friend number of the friend this client is in a call with.
:param control: The control command to send.
:return: True on success.
def toxygen.toxav.ToxAV.callback_audio_receive_frame (   self,
  callback,
  user_data 
)
Set the callback for the `audio_receive_frame` event. Pass None to unset.

:param callback: Python function.
Function for the audio_receive_frame callback. The callback can be called multiple times per single
iteration depending on the amount of queued frames in the buffer. The received format is the same as in send
function.

Should take pointer (c_void_p) to ToxAV object,
The friend number (c_uint32) of the friend who sent an audio frame.
An array (c_uint8) of audio samples (sample_count * channels elements).
The number (c_size_t) of audio samples per channel in the PCM array.
Number (c_uint8) of audio channels.
Sampling rate (c_uint32) used in this frame.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.toxav.ToxAV.callback_call (   self,
  callback,
  user_data 
)
Set the callback for the `call` event. Pass None to unset.

:param callback: The function for the call callback.

Should take pointer (c_void_p) to ToxAV object,
The friend number (c_uint32) from which the call is incoming.
True (c_bool) if friend is sending audio.
True (c_bool) if friend is sending video.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.toxav.ToxAV.callback_call_state (   self,
  callback,
  user_data 
)
Set the callback for the `call_state` event. Pass None to unset.

:param callback: Python function.
The function for the call_state callback.

Should take pointer (c_void_p) to ToxAV object,
The friend number (c_uint32) for which the call state changed.
The bitmask of the new call state which is guaranteed to be different than the previous state. The state is set
to 0 when the call is paused. The bitmask represents all the activities currently performed by the friend.
pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.toxav.ToxAV.callback_video_receive_frame (   self,
  callback,
  user_data 
)
Set the callback for the `video_receive_frame` event. Pass None to unset.

:param callback: Python function.
The function type for the video_receive_frame callback.

Should take
toxAV           pointer (c_void_p) to ToxAV object,
friend_number   The friend number (c_uint32) of the friend who sent a video frame.
width           Width (c_uint16) of the frame in pixels.
height          Height (c_uint16) of the frame in pixels.
y
u
v               Plane data (POINTER(c_uint8)).
            The size of plane data is derived from width and height where
            Y = MAX(width, abs(ystride)) * height,
            U = MAX(width/2, abs(ustride)) * (height/2) and
            V = MAX(width/2, abs(vstride)) * (height/2).
ystride
ustride
vstride         Strides data (c_int32). Strides represent padding for each plane that may or may not be present. You must
        handle strides in your image processing code. Strides are negative if the image is bottom-up
        hence why you MUST abs() it when calculating plane buffer size.
user_data       pointer (c_void_p) to user_data
:param user_data: pointer (c_void_p) to user data
def toxygen.toxav.ToxAV.get_tox_pointer (   self)
Returns the Tox instance the A/V object was created for.

:return: pointer to the Tox instance
def toxygen.toxav.ToxAV.iterate (   self)
Main loop for the session. This function needs to be called in intervals of toxav_iteration_interval()
milliseconds. It is best called in the separate thread from tox_iterate.
def toxygen.toxav.ToxAV.iteration_interval (   self)
Returns the interval in milliseconds when the next toxav_iterate call should be. If no call is active at the
moment, this function returns 200.

:return: interval in milliseconds
def toxygen.toxav.ToxAV.video_send_frame (   self,
  friend_number,
  width,
  height,
  y,
  u,
  v 
)
Send a video frame to a friend.

Y - plane should be of size: height * width
U - plane should be of size: (height/2) * (width/2)
V - plane should be of size: (height/2) * (width/2)

:param friend_number: The friend number of the friend to which to send a video frame.
:param width: Width of the frame in pixels.
:param height: Height of the frame in pixels.
:param y: Y (Luminance) plane data.
:param u: U (Chroma) plane data.
:param v: V (Chroma) plane data.

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