Skip to content

Commit 55cb076

Browse files
author
Vinothini Dharmaraj
committed
updating the comments
1 parent 9883e2f commit 55cb076

File tree

4 files changed

+149
-16
lines changed

4 files changed

+149
-16
lines changed

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/__init__.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
RemoveParticipantResult,
2222
TransferCallResult,
2323
MediaStreamingOptions,
24+
MediaStreamingSubscription,
2425
TranscriptionOptions,
26+
TranscriptionSubscription,
2527
ChannelAffinity,
2628
MuteParticipantResult,
2729
SendDtmfTonesResult,
@@ -30,7 +32,11 @@
3032
ServerCallLocator,
3133
GroupCallLocator,
3234
AzureBlobContainerRecordingStorage,
33-
AzureCommunicationsRecordingStorage
35+
AzureCommunicationsRecordingStorage,
36+
AudioMetadata,
37+
AudioData,
38+
TranscriptionMetadata,
39+
TranscriptionData
3440
)
3541
from ._shared.models import (
3642
CommunicationIdentifier,
@@ -75,9 +81,15 @@
7581
"RecognitionChoice",
7682
"ChannelAffinity",
7783
"MediaStreamingOptions",
84+
"MediaStreamingSubscription",
7885
"TranscriptionOptions",
79-
'AzureBlobContainerRecordingStorage',
80-
'AzureCommunicationsRecordingStorage',
86+
"TranscriptionSubscription",
87+
"AzureBlobContainerRecordingStorage",
88+
"AzureCommunicationsRecordingStorage",
89+
"AudioMetadata",
90+
"AudioData",
91+
"TranscriptionMetadata",
92+
"TranscriptionData",
8193

8294
# models for output
8395
"CallConnectionProperties",

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_call_connection_client.py

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Licensed under the MIT License. See License.txt in the project root for
55
# license information.
66
# --------------------------------------------------------------------------
7-
from typing import TYPE_CHECKING, Optional, List, Union, Dict
7+
from typing import TYPE_CHECKING, Optional, List, Union, Dict, overload
88
from urllib.parse import urlparse
99
import warnings
1010

@@ -411,7 +411,45 @@ def remove_participant(
411411

412412
return RemoveParticipantResult._from_generated(response) # pylint:disable=protected-access
413413

414-
@distributed_trace
414+
@overload
415+
def play_media(
416+
self,
417+
play_source: Union[Union['FileSource', 'TextSource', 'SsmlSource'],
418+
List[Union['FileSource', 'TextSource', 'SsmlSource']]],
419+
play_to: Union[Literal["all"], List['CommunicationIdentifier']] = 'all',
420+
*,
421+
loop: bool = False,
422+
operation_context: Optional[str] = None,
423+
operation_callback_url: Optional[str] = None,
424+
**kwargs
425+
) -> None:
426+
"""Play media to specific participant(s) in this call.
427+
428+
:param play_source: A PlaySource representing the source to play.
429+
:type play_source: ~azure.communication.callautomation.FileSource or
430+
~azure.communication.callautomation.TextSource or
431+
~azure.communication.callautomation.SsmlSource or
432+
list[~azure.communication.callautomation.FileSource] or
433+
list[~azure.communication.callautomation.TextSource] or
434+
list[~azure.communication.callautomation.SsmlSource]
435+
:param play_to: The targets to play media to. Default value is 'all', to play media
436+
to all participants in the call.
437+
:type play_to: list[~azure.communication.callautomation.CommunicationIdentifier]
438+
:keyword loop: Whether the media should be repeated until cancelled.
439+
:paramtype loop: bool
440+
:keyword operation_context: Value that can be used to track this call and its associated events.
441+
:paramtype operation_context: str or None
442+
:keyword operation_callback_url: Set a callback URL that overrides the default callback URL set
443+
by CreateCall/AnswerCall for this operation.
444+
This setup is per-action. If this is not set, the default callback URL set by
445+
CreateCall/AnswerCall will be used.
446+
:paramtype operation_callback_url: str or None
447+
:return: None
448+
:rtype: None
449+
:raises ~azure.core.exceptions.HttpResponseError:
450+
"""
451+
452+
@overload
415453
def play_media(
416454
self,
417455
play_source: Union[Union['FileSource', 'TextSource', 'SsmlSource'],
@@ -452,13 +490,23 @@ def play_media(
452490
:rtype: None
453491
:raises ~azure.core.exceptions.HttpResponseError:
454492
"""
493+
494+
@distributed_trace
495+
def play_media(
496+
self,
497+
play_source: Union[Union['FileSource', 'TextSource', 'SsmlSource'],
498+
List[Union['FileSource', 'TextSource', 'SsmlSource']]],
499+
play_to: Union[Literal["all"], List['CommunicationIdentifier']] = 'all',
500+
**kwargs
501+
) -> None:
502+
455503
self._play_media(
456504
play_source=play_source,
457505
play_to=play_to,
458-
loop=loop,
459-
operation_context=operation_context,
460-
operation_callback_url=operation_callback_url,
461-
interrupt_call_media_operation=interrupt_call_media_operation,
506+
loop=kwargs.pop("loop", False),
507+
operation_context=kwargs.pop("operation_context", None),
508+
operation_callback_url=kwargs.pop("operation_callback_url", None),
509+
interrupt_call_media_operation=kwargs.pop("interrupt_call_media_operation", None),
462510
**kwargs
463511
)
464512

@@ -1001,7 +1049,8 @@ def hold(
10011049

10021050
hold_request=HoldRequest(
10031051
target_participant=serialize_identifier(target_participant),
1004-
play_source_info=play_source_single._to_generated() if play_source_single else None, # pylint:disable=protected-access
1052+
play_source_info=play_source_single._to_generated() # pylint:disable=protected-access
1053+
if play_source_single else None,
10051054
operation_context=operation_context,
10061055
operation_callback_uri=operation_callback_url,
10071056
kwargs=kwargs

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/aio/_call_connection_client_async.py

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Licensed under the MIT License. See License.txt in the project root for
55
# license information.
66
# --------------------------------------------------------------------------
7-
from typing import TYPE_CHECKING, Optional, List, Union, Dict
7+
from typing import TYPE_CHECKING, Optional, List, Union, Dict, overload
88
from urllib.parse import urlparse
99
import warnings
1010

@@ -416,7 +416,48 @@ async def remove_participant(
416416

417417
return RemoveParticipantResult._from_generated(response) # pylint:disable=protected-access
418418

419-
@distributed_trace_async
419+
@overload
420+
async def play_media(
421+
self,
422+
play_source: Union[Union['FileSource', 'TextSource', 'SsmlSource'],
423+
List[Union['FileSource', 'TextSource', 'SsmlSource']]],
424+
play_to: Union[Literal["all"], List['CommunicationIdentifier']] = 'all',
425+
*,
426+
loop: bool = False,
427+
operation_context: Optional[str] = None,
428+
operation_callback_url: Optional[str] = None,
429+
**kwargs
430+
) -> None:
431+
"""Play media to specific participant(s) in this call.
432+
433+
:param play_source: A PlaySource representing the source to play.
434+
:type play_source: ~azure.communication.callautomation.FileSource or
435+
~azure.communication.callautomation.TextSource or
436+
~azure.communication.callautomation.SsmlSource or
437+
list[~azure.communication.callautomation.FileSource] or
438+
list[~azure.communication.callautomation.TextSource] or
439+
list[~azure.communication.callautomation.SsmlSource]
440+
:param play_to: The targets to play media to. Default value is 'all', to play media
441+
to all participants in the call.
442+
:type play_to: list[~azure.communication.callautomation.CommunicationIdentifier]
443+
:keyword loop: Whether the media should be repeated until cancelled.
444+
:paramtype loop: bool
445+
:keyword operation_context: Value that can be used to track this call and its associated events.
446+
:paramtype operation_context: str or None
447+
:keyword operation_callback_url: Set a callback URL that overrides the default callback URL set
448+
by CreateCall/AnswerCall for this operation.
449+
This setup is per-action. If this is not set, the default callback URL set by
450+
CreateCall/AnswerCall will be used.
451+
:paramtype operation_callback_url: str or None
452+
:keyword interrupt_call_media_operation: If set play can barge into other existing
453+
queued-up/currently-processing requests. This is applicable only when play_to set to all.
454+
:paramtype interrupt_call_media_operation: bool
455+
:return: None
456+
:rtype: None
457+
:raises ~azure.core.exceptions.HttpResponseError:
458+
"""
459+
460+
@overload
420461
async def play_media(
421462
self,
422463
play_source: Union[Union['FileSource', 'TextSource', 'SsmlSource'],
@@ -457,13 +498,23 @@ async def play_media(
457498
:rtype: None
458499
:raises ~azure.core.exceptions.HttpResponseError:
459500
"""
501+
502+
@distributed_trace_async
503+
async def play_media(
504+
self,
505+
play_source: Union[Union['FileSource', 'TextSource', 'SsmlSource'],
506+
List[Union['FileSource', 'TextSource', 'SsmlSource']]],
507+
play_to: Union[Literal["all"], List['CommunicationIdentifier']] = 'all',
508+
**kwargs
509+
) -> None:
510+
460511
await self._play_media(
461512
play_source=play_source,
462513
play_to=play_to,
463-
loop=loop,
464-
operation_context=operation_context,
465-
operation_callback_url=operation_callback_url,
466-
interrupt_call_media_operation=interrupt_call_media_operation,
514+
loop=kwargs.pop("loop", False),
515+
operation_context=kwargs.pop("operation_context", None),
516+
operation_callback_url=kwargs.pop("operation_callback_url", None),
517+
interrupt_call_media_operation=kwargs.pop("interrupt_call_media_operation", None),
467518
**kwargs
468519
)
469520

sdk/communication/azure-communication-callautomation/tests/test_call_media_client.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,27 @@ def test_play_file_to_all_back_compat(self):
121121
self.assertEqual(expected_play_request.play_to, actual_play_request.play_to)
122122
self.assertEqual(expected_play_request.play_options, actual_play_request.play_options)
123123

124+
def test_play_file_back_compat_with_barge_in_play_media(self):
125+
mock_play = Mock()
126+
self.call_media_operations.play = mock_play
127+
play_source = FileSource(url=self.url)
128+
129+
self.call_connection_client.play_media(play_source=play_source, interrupt_call_media_operation=True)
130+
131+
expected_play_request = PlayRequest(
132+
play_sources=[play_source._to_generated()],
133+
play_to=[],
134+
play_options=PlayOptions(loop=False, interrupt_call_media_operation=True)
135+
)
136+
mock_play.assert_called_once()
137+
actual_play_request = mock_play.call_args[0][1]
138+
139+
self.assertEqual(expected_play_request.play_sources[0].kind, actual_play_request.play_sources[0].kind)
140+
self.assertEqual(expected_play_request.play_sources[0].file.uri, actual_play_request.play_sources[0].file.uri)
141+
self.assertEqual(expected_play_request.play_sources[0].play_source_cache_id, actual_play_request.play_sources[0].play_source_cache_id)
142+
self.assertEqual(expected_play_request.play_to, actual_play_request.play_to)
143+
self.assertEqual(expected_play_request.play_options, actual_play_request.play_options)
144+
124145
def test_play_file_to_all_back_compat_with_barge_in(self):
125146
mock_play = Mock()
126147
self.call_media_operations.play = mock_play

0 commit comments

Comments
 (0)