def create(cmd, client, resource_group_name, account_name, live_event_name, streaming_protocol, ips, # pylint: disable=too-many-locals auto_start=False, encoding_type=None, preset_name=None, tags=None, description=None, key_frame_interval_duration=None, access_token=None, no_wait=False, preview_ips=None, preview_locator=None, streaming_policy_name=None, alternative_media_id=None, vanity_url=False, client_access_policy=None, cross_domain_policy=None, stream_options=None): from azure.mgmt.media.models import (LiveEventInputProtocol, LiveEventInput, LiveEvent, LiveEventEncoding, LiveEventInputAccessControl, IPAccessControl) from azure.cli.command_modules.ams._client_factory import (get_mediaservices_client) allowed_ips = [] if ips[0] == 'AllowAll': ips = ['0.0.0.0/0'] for ip in ips: allowed_ips.append(create_ip_range(live_event_name, ip)) live_event_input_access_control = LiveEventInputAccessControl(ip=IPAccessControl(allow=allowed_ips)) live_event_input = LiveEventInput(streaming_protocol=LiveEventInputProtocol(streaming_protocol), access_token=access_token, key_frame_interval_duration=key_frame_interval_duration, access_control=live_event_input_access_control) ams_client = get_mediaservices_client(cmd.cli_ctx) ams = ams_client.get(resource_group_name, account_name) location = ams.location live_event_preview = create_live_event_preview(preview_locator, streaming_policy_name, alternative_media_id, preview_ips, live_event_name) policies = create_cross_site_access_policies(client_access_policy, cross_domain_policy) live_event = LiveEvent(input=live_event_input, location=location, preview=live_event_preview, encoding=LiveEventEncoding(encoding_type=encoding_type, preset_name=preset_name), tags=tags, vanity_url=vanity_url, stream_options=stream_options, cross_site_access_policies=policies, description=description) return sdk_no_wait(no_wait, client.create, resource_group_name=resource_group_name, account_name=account_name, live_event_name=live_event_name, parameters=live_event, auto_start=auto_start)
# See REST API documentation for the details on each setting value # https://docs.microsoft.com/rest/api/media/liveevents/create live_event_create = LiveEvent( location="West US 2", # For the sample, we are using location: West US 2 description="Sample 720P Encoding Live Event from Python SDK sample", # Set useStaticHostname to true to make the ingest and preview URL host name the same. # This can slow things down a bit. use_static_hostname=True, # hostname_prefix= "somethingstatic", # When using Static host name true, you can control the host prefix name here if desired # 1) Set up the input settings for the Live event... input=LiveEventInput( streaming_protocol=LiveEventInputProtocol. RTMP, # Options are RTMP or Smooth Streaming ingest format. access_control= live_event_input_access, # controls the IP restriction for the source header # key_frame_interval_duration = timedelta(seconds = 2), # Set this to match the ingest encoder's settings. This should not be used for encoding channels access_token= '9eb1f703b149417c8448771867f48501' # Use this value when you want to make sure the ingest URL is static and always the same. If omited, the service will generate a random GUID values. ), # 2) Set the live event to use pass-through or cloud encoding modes... encoding=LiveEventEncoding( # Set this to Basic pass-through, Standard pass-through, Standard or Premium1080P to use the cloud live encoder. # See https://go.microsoft.com/fwlink/?linkid=2095101 for more information # Otherwise, leave as "None" to use pass-through mode encoding_type=LiveEventEncodingType.STANDARD, # OPTIONS for encoding type you can use: # encoding_type=LiveEventEncodingType.PassthroughBasic, # Basic pass-through mode - the cheapest option! # encoding_type=LiveEventEncodingType.PassthroughStandard, # also known as standard pass-through mode (formerly "none") # encoding_type=LiveEventEncodingType.Premium1080p, # live transcoding up to 1080P 30fps with adaptive bitrate set