Skip to main content

Vonage video package

Project description

Vonage Video API

This package contains the code to use Vonage's Video API in Python. This package includes methods for working with video sessions, streams, signals, and more.

Usage

It is recommended to use this as part of the main vonage package. The examples below assume you've created an instance of the vonage.Vonage class called vonage_client.

You will use the custom Pydantic data models to make most of the API calls in this package. They are accessed from the vonage_video.models package.

Generate a Client Token

from vonage_video.models import TokenOptions

token_options = TokenOptions(session_id='your_session_id', role='publisher')
client_token = vonage_client.video.generate_client_token(token_options)

Create a Session

from vonage_video.models import SessionOptions

session_options = SessionOptions(media_mode='routed')
video_session = vonage_client.video.create_session(session_options)

List Streams

streams = vonage_client.video.list_streams(session_id='your_session_id')

Get a Stream

stream_info = vonage_client.video.get_stream(session_id='your_session_id', stream_id='your_stream_id')

Change Stream Layout

from vonage_video.models import StreamLayoutOptions

layout_options = StreamLayoutOptions(type='bestFit')
updated_streams = vonage_client.video.change_stream_layout(session_id='your_session_id', stream_layout_options=layout_options)

Send a Signal

from vonage_video.models import SignalData

signal_data = SignalData(type='chat', data='Hello, World!')
vonage_client.video.send_signal(session_id='your_session_id', data=signal_data)

Disconnect a Client

vonage_client.video.disconnect_client(session_id='your_session_id', connection_id='your_connection_id')

Mute a Stream

vonage_client.video.mute_stream(session_id='your_session_id', stream_id='your_stream_id')

Mute All Streams

vonage_client.video.mute_all_streams(session_id='your_session_id', excluded_stream_ids=['stream_id_1', 'stream_id_2'])

Disable Mute All Streams

vonage_client.video.disable_mute_all_streams(session_id='your_session_id')

Start Captions

from vonage_video.models import CaptionsOptions

captions_options = CaptionsOptions(language='en-US')
captions_data = vonage_client.video.start_captions(captions_options)

Stop Captions

from vonage_video.models import CaptionsData

captions_data = CaptionsData(captions_id='your_captions_id')
vonage_client.video.stop_captions(captions_data)

Start Audio Connector

from vonage_video.models import AudioConnectorOptions

audio_connector_options = AudioConnectorOptions(session_id='your_session_id', token='your_token', url='https://example.com')
audio_connector_data = vonage_client.video.start_audio_connector(audio_connector_options)

Start Experience Composer

from vonage_video.models import ExperienceComposerOptions

experience_composer_options = ExperienceComposerOptions(session_id='your_session_id', token='your_token', url='https://example.com')
experience_composer = vonage_client.video.start_experience_composer(experience_composer_options)

List Experience Composers

from vonage_video.models import ListExperienceComposersFilter

filter = ListExperienceComposersFilter(page_size=10)
experience_composers, count, next_page_offset = vonage_client.video.list_experience_composers(filter)
print(experience_composers)

Get Experience Composer

experience_composer = vonage_client.video.get_experience_composer(experience_composer_id='experience_composer_id')

Stop Experience Composer

vonage_client.video.stop_experience_composer(experience_composer_id='experience_composer_id')

List Archives

from vonage_video.models import ListArchivesFilter

filter = ListArchivesFilter(offset=2)
archives, count, next_page_offset = vonage_client.video.list_archives(filter)
print(archives)

Start Archive

from vonage_video.models import CreateArchiveRequest

archive_options = CreateArchiveRequest(session_id='your_session_id', name='My Archive')
archive = vonage_client.video.start_archive(archive_options)

Get Archive

archive = vonage_client.video.get_archive(archive_id='your_archive_id')
print(archive)

Delete Archive

vonage_client.video.delete_archive(archive_id='your_archive_id')

Add Stream to Archive

from vonage_video.models import AddStreamRequest

add_stream_request = AddStreamRequest(stream_id='your_stream_id')
vonage_client.video.add_stream_to_archive(archive_id='your_archive_id', params=add_stream_request)

Remove Stream from Archive

vonage_client.video.remove_stream_from_archive(archive_id='your_archive_id', stream_id='your_stream_id')

Stop Archive

archive = vonage_client.video.stop_archive(archive_id='your_archive_id')
print(archive)

Change Archive Layout

from vonage_video.models import ComposedLayout

layout = ComposedLayout(type='bestFit')
archive = vonage_client.video.change_archive_layout(archive_id='your_archive_id', layout=layout)
print(archive)

List Broadcasts

from vonage_video.models import ListBroadcastsFilter

filter = ListBroadcastsFilter(page_size=10)
broadcasts, count, next_page_offset = vonage_client.video.list_broadcasts(filter)
print(broadcasts)

Start Broadcast

from vonage_video.models import CreateBroadcastRequest, BroadcastOutputSettings, BroadcastHls, BroadcastRtmp

broadcast_options = CreateBroadcastRequest(session_id='your_session_id', outputs=BroadcastOutputSettings(
    hls=BroadcastHls(dvr=True, low_latency=False),
    rtmp=[
        BroadcastRtmp(
            id='test',
            server_url='rtmp://a.rtmp.youtube.com/live2',
            stream_name='stream-key',
        )
    ],
)
)
broadcast = vonage_client.video.start_broadcast(broadcast_options)
print(broadcast)

Get Broadcast

broadcast = vonage_client.video.get_broadcast(broadcast_id='your_broadcast_id')
print(broadcast)

Stop Broadcast

broadcast = vonage_client.video.stop_broadcast(broadcast_id='your_broadcast_id')
print(broadcast)

Change Broadcast Layout

from vonage_video.models import ComposedLayout

layout = ComposedLayout(type='bestFit')
broadcast = vonage_client.video.change_broadcast_layout(broadcast_id='your_broadcast_id', layout=layout)
print(broadcast)

Add Stream to Broadcast

from vonage_video.models import AddStreamRequest

add_stream_request = AddStreamRequest(stream_id='your_stream_id')
vonage_client.video.add_stream_to_broadcast(broadcast_id='your_broadcast_id', params=add_stream_request)

Remove Stream from Broadcast

vonage_client.video.remove_stream_from_broadcast(broadcast_id='your_broadcast_id', stream_id='your_stream_id')

Initiate SIP Call

from vonage_video.models import InitiateSipRequest, SipOptions, SipAuth

sip_request_params = InitiateSipRequest(
    session_id='your_session_id',
    token='your_token',
    sip=SipOptions(
        uri=f'sip:{vonage_number}@sip.nexmo.com;transport=tls',
        from_=f'test@vonage.com',
        headers={'header_key': 'header_value'},
        auth=SipAuth(username='1485b9e6', password='fL8jvi4W2FmS9som'),
        secure=False,
        video=False,
        observe_force_mute=True,
    ),
)
sip_call = vonage_client.video.initiate_sip_call(sip_request_params)
print(sip_call)

Play DTMF into a call

# Play into all connections
session_id = 'your_session_id'
digits = '1234#*p'

vonage_client.video.play_dtmf(session_id=session_id, digits=digits)

# Play into one connection
session_id = 'your_session_id'
digits = '1234#*p'
connection_id = 'your_connection_id'

vonage_client.video.play_dtmf(session_id=session_id, digits=digits, connection_id=connection_id)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vonage_video-1.0.4.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vonage_video-1.0.4-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file vonage_video-1.0.4.tar.gz.

File metadata

  • Download URL: vonage_video-1.0.4.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.4

File hashes

Hashes for vonage_video-1.0.4.tar.gz
Algorithm Hash digest
SHA256 44860f0ccf29cfa81d9d07c8d97f62c52782b14693729be3c286d21830df0b58
MD5 a3469a4125e5e6d9d4c909905d5c4597
BLAKE2b-256 2ad626b733ec753e76a57274a381f0809b03834f34b60e9dddd2eeadd26d8d3e

See more details on using hashes here.

File details

Details for the file vonage_video-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: vonage_video-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.4

File hashes

Hashes for vonage_video-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9d1b199c302d4b95442110234ad3c05b78426b5295cfe17a52e5761f8eeff007
MD5 14601df3c48626431efaf8d1c4d71b0e
BLAKE2b-256 1d961c3b2aa560c2ab00e64a05c3fb447738b57e8e3c2e5ce2f77e1873e80906

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page