Amazon.CDK.AWS.MediaConnect.Alpha
The CDK construct library for AWS Elemental MediaConnect (Stability: Experimental)
Install
| Product | Versions |
|---|---|
| .NET |
README
AWS::MediaConnect Construct Library
The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
AWS Elemental MediaConnect
AWS Elemental MediaConnect is a high-quality transport service for live video. It provides the reliability and security of satellite and fiber-optic combined with the flexibility, agility, and economics of IP-based networks. MediaConnect enables you to build mission-critical live video workflows in a fraction of the time and cost of satellite or fiber services.
This package contains constructs for working with AWS Elemental MediaConnect, allowing you to define Flows, Bridges, Gateways, Router Inputs, Router Outputs, and Router Network Interfaces for transporting live video streams.
For further information on AWS Elemental MediaConnect, see the documentation.
Table of Contents
Router Resources
MediaConnect routers provide high-performance, low-latency video routing capabilities for building complex live video workflows. Router resources include network interfaces, inputs, and outputs.
How Router Resources Relate
Router resources work together in a pipeline:
- A RouterNetworkInterface defines the network connectivity (public internet or VPC). Required for standard protocol-based inputs and outputs, but not needed when connecting to MediaLive inputs or MediaConnect flows directly.
- A RouterInput is the entry point β it receives video from a source via a protocol (RTP, SRT, RIST), or from a MediaConnect flow.
- A RouterOutput is the exit point β it sends video to a destination via a protocol, to a MediaLive input, or to a MediaConnect flow.
A typical camera-to-cloud workflow looks like:
Camera β RouterNetworkInterface β RouterInput (SRT) β [Router] β RouterOutput (MediaLive) β MediaLive Channel
The router sits in the middle, routing content from inputs to outputs. You can have many outputs per input β for example, one camera feed going to both a MediaLive channel and a MediaConnect flow simultaneously.
End-to-End Example: SRT Source to MediaLive
Here's a complete example showing how to connect an SRT source through a router to MediaLive:
Stack stack;
IInput mediaLiveInput;
// 1. A public network interface for the SRT input
var networkInterface = new RouterNetworkInterface(stack, "NetworkInterface", new RouterNetworkInterfaceProps {
RouterNetworkInterfaceName = "camera-network",
Configuration = RouterNetworkConfiguration.PublicNetwork(new PublicNetworkConfigurationProps {
Cidr = new [] { "203.0.113.0/24" }
})
});
// 2. A router input receiving SRT from an upstream encoder
var input = new RouterInput(stack, "Input", new RouterInputProps {
RouterInputName = "camera-input",
MaximumBitrate = Bitrate.Mbps(10),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterInputTier.INPUT_20,
Configuration = RouterInputConfiguration.Standard(new StandardConfigurationProps {
NetworkInterface = networkInterface,
Protocol = RouterInputProtocol.SrtListener(new SrtListenerProtocolProps {
Port = 9000,
MinimumLatency = Duration.Millis(200)
})
})
});
// 3. A router output delivering to MediaLive
var output = new RouterOutput(stack, "Output", new RouterOutputProps {
RouterOutputName = "medialive-output",
MaximumBitrate = Bitrate.Mbps(10),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterOutputTier.OUTPUT_20,
Configuration = RouterOutputConfiguration.MediaLiveInput(new MediaLiveInputConnectionProps {
Input = mediaLiveInput,
Pipeline = MediaLivePipeline.PIPELINE_0
})
});
This gives you a complete pipeline: the encoder pushes SRT to the network interface, the router receives it as an input, and the router output delivers it to MediaLive. For routing rules β including how bitrate affects which outputs can receive which inputs β see the documentation.
Router Network Interfaces
Network interfaces define the network connectivity for router inputs and outputs:
Public Network Interface
Stack stack;
var publicInterface = new RouterNetworkInterface(stack, "PublicInterface", new RouterNetworkInterfaceProps {
RouterNetworkInterfaceName = "public-interface",
Configuration = RouterNetworkConfiguration.PublicNetwork(new PublicNetworkConfigurationProps {
Cidr = new [] { "203.0.113.0/24" }
})
});
Private Network Interface
Stack stack;
ISecurityGroup securityGroup;
ISubnet subnet;
var privateInterface = new RouterNetworkInterface(stack, "PrivateInterface", new RouterNetworkInterfaceProps {
RouterNetworkInterfaceName = "private-interface",
Configuration = RouterNetworkConfiguration.Vpc(new VpcNetworkConfigurationProps {
SecurityGroups = new [] { securityGroup },
Subnet = subnet
})
});
Router Inputs
Router inputs receive live video streams from various sources and make them available for routing:
Standard Input with RTP Protocol
Stack stack;
RouterNetworkInterface networkInterface;
var input = new RouterInput(stack, "RtpInput", new RouterInputProps {
RouterInputName = "rtp-input",
MaximumBitrate = Bitrate.Mbps(10),
RoutingScope = RoutingScope.REGIONAL,
// tier defaults to RouterInputTier.INPUT_20 (lowest cost)
Configuration = RouterInputConfiguration.Standard(new StandardConfigurationProps {
NetworkInterface = networkInterface,
Protocol = RouterInputProtocol.Rtp(new RtpProtocolProps {
Port = 5000
})
})
});
Failover Input Configuration
Stack stack;
RouterNetworkInterface networkInterface;
var input = new RouterInput(stack, "FailoverInput", new RouterInputProps {
RouterInputName = "failover-input",
MaximumBitrate = Bitrate.Mbps(10),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterInputTier.INPUT_20,
Configuration = RouterInputConfiguration.Failover(new FailoverConfigurationProps {
NetworkInterface = networkInterface,
Protocols = new [] { RouterInputProtocol.Rist(new RistProtocolProps {
Port = 5000,
RecoveryLatency = Duration.Millis(1000)
}), RouterInputProtocol.Rist(new RistProtocolProps {
Port = 5002, // Must not be consecutive with primary port
RecoveryLatency = Duration.Millis(1000)
}) },
SourcePriority = SourcePriorityConfig.PrimarySecondary(PrimarySource.FIRST_SOURCE)
})
});
MediaLive Channel Input
Connect a router input to a MediaLive channel. The outputName must match the name of an output configured in the channel's MediaConnect Router output group.
Stack stack;
IChannel mediaLiveChannel;
var input = new RouterInput(stack, "ChannelInput", new RouterInputProps {
RouterInputName = "channel-input",
MaximumBitrate = Bitrate.Mbps(20),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterInputTier.INPUT_20,
Configuration = RouterInputConfiguration.MediaLiveChannel(new MediaLiveChannelConfigurationProps {
Channel = mediaLiveChannel,
OutputName = "router-ts",
Pipeline = MediaLivePipeline.PIPELINE_0
})
});
Tip: For full examples of wiring a MediaLive channel to a MediaConnect Router (including transit encryption), see the MediaLive L2 README β MediaConnect Router section.
Stack stack;
IChannel mediaLiveChannel;
Secret transitSecret;
// must hold the same value as the channel's MediaConnectRouterSettings.shared() secret
var input = new RouterInput(stack, "ChannelInput", new RouterInputProps {
RouterInputName = "channel-input",
MaximumBitrate = Bitrate.Mbps(20),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterInputTier.INPUT_20,
Configuration = RouterInputConfiguration.MediaLiveChannel(new MediaLiveChannelConfigurationProps {
Channel = mediaLiveChannel,
OutputName = "router-ts",
Pipeline = MediaLivePipeline.PIPELINE_0,
SourceTransitDecryption = new TransitEncryption { Secret = transitSecret }
})
});
Or prepare a router input for a MediaLive connection without specifying the channel (requires explicit availability zone):
Stack stack;
var input = new RouterInput(stack, "ChannelInputNoConnection", new RouterInputProps {
RouterInputName = "channel-input-no-connection",
MaximumBitrate = Bitrate.Mbps(20),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterInputTier.INPUT_20,
Configuration = RouterInputConfiguration.MediaLiveChannelWithoutConnection(new MediaLiveChannelConfigurationWithoutConnectionProps {
AvailabilityZone = "us-east-1a"
})
});
MediaConnect Flow Input
Connect a router input to an existing MediaConnect flow:
Stack stack;
Flow flow;
FlowOutput flowOutput;
var input = new RouterInput(stack, "FlowInput", new RouterInputProps {
RouterInputName = "flow-input",
MaximumBitrate = Bitrate.Mbps(20),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterInputTier.INPUT_20,
Configuration = RouterInputConfiguration.MediaConnectFlow(new MediaConnectFlowConfigurationProps {
Flow = flow,
FlowOutput = flowOutput
})
});
Or prepare a router input for a flow connection without specifying the flow (requires explicit availability zone):
Stack stack;
var input = new RouterInput(stack, "FlowInputNoConnection", new RouterInputProps {
RouterInputName = "flow-input-no-connection",
MaximumBitrate = Bitrate.Mbps(20),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterInputTier.INPUT_20,
Configuration = RouterInputConfiguration.MediaConnectFlowWithoutConnection(new MediaConnectFlowConfigurationWithoutConnectionProps {
AvailabilityZone = "us-east-1a"
})
});
Router Outputs
Router outputs send video streams to various destinations including standard protocols, MediaLive inputs, and MediaConnect flows:
Standard Output with SRT Protocol
Stack stack;
RouterNetworkInterface networkInterface;
var output = new RouterOutput(stack, "SrtOutput", new RouterOutputProps {
RouterOutputName = "srt-output",
MaximumBitrate = Bitrate.Mbps(10),
RoutingScope = RoutingScope.REGIONAL,
// tier defaults to RouterOutputTier.OUTPUT_20 (lowest cost)
Configuration = RouterOutputConfiguration.Standard(new StandardOutputConfigurationProps {
Protocol = RouterOutputProtocol.SrtListener(new SrtListenerOutputProtocolProps {
Port = 9001,
MinimumLatency = Duration.Millis(200)
}),
NetworkInterface = networkInterface
})
});
Note: The
tierproperty defaults to the lowest (and cheapest) tier:INPUT_20for Router Inputs andOUTPUT_20for Router Outputs. The construct validates thatmaximumBitratedoes not exceed the tier's capacity (20, 50, or 100 Mbps) at synth time. Per the documentation, if an input is 20 Mbps you can't route it to an output set up for less than 20 Mbps.
MediaLive Output
Connect a router output to a MediaLive input (the input must be a MediaConnect Router type):
Stack stack;
IInput mediaLiveInput;
var output = new RouterOutput(stack, "MediaLiveOutput", new RouterOutputProps {
RouterOutputName = "medialive-output",
MaximumBitrate = Bitrate.Mbps(15),
RoutingScope = RoutingScope.GLOBAL,
Tier = RouterOutputTier.OUTPUT_20,
Configuration = RouterOutputConfiguration.MediaLiveInput(new MediaLiveInputConnectionProps {
Input = mediaLiveInput,
Pipeline = MediaLivePipeline.PIPELINE_0
})
});
Or prepare a router output for a MediaLive connection without specifying the input (requires explicit availability zone):
Stack stack;
var output = new RouterOutput(stack, "MediaLiveOutputNoConnection", new RouterOutputProps {
RouterOutputName = "medialive-output-no-connection",
MaximumBitrate = Bitrate.Mbps(15),
RoutingScope = RoutingScope.GLOBAL,
Tier = RouterOutputTier.OUTPUT_20,
Configuration = RouterOutputConfiguration.MediaLiveInputWithoutConnection(new MediaLiveNoInputConnectionProps {
AvailabilityZone = "us-east-1a"
})
});
MediaConnect Flow Output
Connect a router output to an existing MediaConnect flow:
Stack stack;
Flow flow;
var output = new RouterOutput(stack, "FlowOutput", new RouterOutputProps {
RouterOutputName = "flow-output",
MaximumBitrate = Bitrate.Mbps(20),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterOutputTier.OUTPUT_20,
Configuration = RouterOutputConfiguration.MediaConnectFlow(new MediaConnectFlowConnectionProps {
Flow = flow
})
});
Or prepare a router output for a flow connection without specifying the flow (requires explicit availability zone):
Stack stack;
var output = new RouterOutput(stack, "FlowOutputNoConnection", new RouterOutputProps {
RouterOutputName = "flow-output-no-connection",
MaximumBitrate = Bitrate.Mbps(20),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterOutputTier.OUTPUT_20,
Configuration = RouterOutputConfiguration.MediaConnectFlowWithoutConnection(new MediaConnectFlowNoConnectionProps {
AvailabilityZone = "us-east-1a"
})
});
Output with Encryption
Stack stack;
RouterNetworkInterface networkInterface;
IRole role;
ISecret secret;
var output = new RouterOutput(stack, "EncryptedOutput", new RouterOutputProps {
RouterOutputName = "encrypted-output",
MaximumBitrate = Bitrate.Mbps(10),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterOutputTier.OUTPUT_20,
Configuration = RouterOutputConfiguration.Standard(new StandardOutputConfigurationProps {
Protocol = RouterOutputProtocol.SrtCaller(new SrtCallerOutputProtocolProps {
DestinationAddress = "203.0.113.100",
DestinationPort = 9001,
MinimumLatency = Duration.Millis(200),
EncryptionConfiguration = new RouterSrtEncryption { Role = role, Secret = secret }
}),
NetworkInterface = networkInterface
})
});
Flows
A MediaConnect flow represents a transport stream connection between a source and one or more outputs. Flows are the primary resource for transporting live video content.
Creating a Flow
The following example creates a basic MediaConnect flow with an RTP source:
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
FlowName = "my-live-stream",
Source = SourceConfiguration.Rtp(new SourceRtp {
FlowSourceName = "my-source",
Port = 5000,
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24")
})
});
Flow Sources
MediaConnect supports multiple source types for ingesting content into a flow. The examples below use NetworkConfiguration.publicNetwork() for simplicity, but all protocol-based sources can also use NetworkConfiguration.vpc() with a VPC interface for private connectivity.
SRT Listener Source
SRT (Secure Reliable Transport) in listener mode configures MediaConnect to listen on a specific port for incoming content. The upstream device connects to MediaConnect as a caller.
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.SrtListener(new SourceSrtListener {
FlowSourceName = "live-encoder-source",
Description = "Live encoder feed",
Port = 5000,
MinLatency = Duration.Millis(2000),
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24")
})
});
SRT Caller Source
SRT in caller mode configures MediaConnect to connect to a remote SRT listener. Use this when the source device is listening for incoming connections rather than pushing content.
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.SrtCaller(new SourceSrtCaller {
FlowSourceName = "remote-source",
SourceListenerAddress = "203.0.113.50",
SourceListenerPort = 5000,
MinLatency = Duration.Millis(200)
})
});
RTP Source
RTP (Real-time Transport Protocol) is a standard protocol for delivering audio and video over IP networks.
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.Rtp(new SourceRtp {
FlowSourceName = "rtp-source",
Port = 5000,
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24")
})
});
RTP-FEC Source
RTP with Forward Error Correction adds redundancy to recover lost packets without retransmission. Use this when contributing via RTP and you need packet recovery.
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.RtpFec(new SourceRtp {
FlowSourceName = "rtp-fec-source",
Port = 5000,
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24")
})
});
RIST Source
RIST (Reliable Internet Stream Transport) provides reliable video transport with packet recovery.
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.Rist(new SourceRist {
FlowSourceName = "rist-source",
Port = 5000,
MaxLatency = Duration.Millis(2000),
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24")
})
});
Zixi Push Source
Zixi Push uses the Zixi protocol for reliable video transport. Content is pushed to MediaConnect from a Zixi-compatible component upstream.
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.ZixiPush(new SourceZixiPush {
FlowSourceName = "zixi-source",
MaxLatency = Duration.Millis(2000),
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24")
})
});
Zixi Push ports are assigned by MediaConnect: 2088 for public sources, 2090-2099 for VPC sources. See Source port assignments.
Router Source
Use a router source when the flow's source comes from a MediaConnect Router rather than a direct connection.
Stack stack;
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.Router()
});
VPC Source
Use a VPC-based source when you need a connection between a flow and your Amazon VPC. This enables private connectivity for receiving content from on-premises equipment via AWS Direct Connect or VPN, or from other AWS services running in your VPC.
Stack stack;
ISecurityGroup securityGroup;
ISubnet subnet;
IRole role;
var vpcInterface = VpcInterface.Define(new VpcInterfaceDefineProps {
VpcInterfaceName = "my-vpc-interface",
Role = role,
SecurityGroups = new [] { securityGroup },
Subnet = subnet
});
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.Rist(new SourceRist {
FlowSourceName = "vpc-source",
Description = "VPC-based source",
Port = 5000,
MaxLatency = Duration.Millis(2000),
Network = NetworkConfiguration.Vpc(vpcInterface)
}),
VpcInterfaces = new [] { vpcInterface }
});
Entitled Source (From Another AWS Account)
Entitlements allow you to subscribe to content from another AWS account. The entitlement is created by the content originator in their AWS account, and you import it using the entitlement ARN they provide.
Stack stack;
// Import an entitlement from another AWS account
var entitlement = FlowEntitlement.FromFlowEntitlementArn(stack, "ImportedEntitlement", "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11111111111111111111111111111111:MyEntitlement");
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.Entitlement(new EntitlementSource {
Entitlement = entitlement
})
});
Gateway Bridge Source
Use a gateway bridge source when ingesting content from on-premises equipment through a MediaConnect gateway and bridge. Gateways define the network infrastructure that bridges use to transport video between on-premises and cloud environments.
Stack stack;
Bridge bridge;
IRole role;
ISecurityGroup securityGroup;
ISubnet subnet;
var vpcInterface = VpcInterface.Define(new VpcInterfaceDefineProps {
VpcInterfaceName = "bridge-interface",
Role = role,
SecurityGroups = new [] { securityGroup },
Subnet = subnet
});
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.GatewayBridge(new GatewayBridgeSource {
Bridge = bridge,
VpcInterface = vpcInterface
}),
VpcInterfaces = new [] { vpcInterface }
});
VPC Interfaces
VPC interfaces allow MediaConnect to send or receive content within your VPC. Create VPC interfaces using VpcInterface.define() and add them to the flow's vpcInterfaces array. The same interface can then be referenced in sources and outputs:
Stack stack;
IRole role;
ISecurityGroup securityGroup;
ISubnet subnet;
// Create VPC interface
var vpcInterface = VpcInterface.Define(new VpcInterfaceDefineProps {
VpcInterfaceName = "my-vpc-interface",
Role = role,
SecurityGroups = new [] { securityGroup },
Subnet = subnet,
NetworkInterfaceType = NetworkInterface.ENA
});
// Add to flow and reference in source
var flow = new Flow(stack, "MyFlow", new FlowProps {
VpcInterfaces = new [] { vpcInterface }, // Declare at flow level
Source = SourceConfiguration.Rist(new SourceRist {
FlowSourceName = "vpc-source",
Port = 5000,
MaxLatency = Duration.Millis(2000),
Network = NetworkConfiguration.Vpc(vpcInterface)
})
});
CDI and JPEG XS with EFA Interfaces
For high-performance CDI or JPEG XS workflows, use EFA (Elastic Fabric Adapter) interfaces. Note that flows can have a maximum of 1 EFA interface:
Stack stack;
IRole role;
ISecurityGroup securityGroup;
ISubnet subnet;
var efaInterface = VpcInterface.Define(new VpcInterfaceDefineProps {
VpcInterfaceName = "efa-interface",
Role = role,
SecurityGroups = new [] { securityGroup },
Subnet = subnet,
NetworkInterfaceType = NetworkInterface.EFA
});
var videoStream = MediaStream.Video(new MediaStreamVideo {
MediaStreamId = 1,
MediaStreamName = "video",
VideoFormat = MediaVideoFormat.HD_1080P,
Fmtp = new FmtpVideo {
ExactFramerate = Framerate.FPS_29_97,
Par = PixelAspectRatio.SQUARE
}
});
var flow = new Flow(stack, "MyCdiFlow", new FlowProps {
FlowSize = FlowSize.LARGE_4X, // Required for CDI and JPEG XS
VpcInterfaces = new [] { efaInterface },
MediaStreams = new [] { videoStream },
Source = SourceConfiguration.Cdi(new SourceCdi {
FlowSourceName = "cdi-source",
VpcInterface = efaInterface,
Port = 5000,
MaxSyncBuffer = 100,
MediaStreamSourceConfigurations = new [] { new MediaStreamSourceConfigurationCdi {
Encoding = Encoding.RAW,
MediaStream = videoStream
} }
})
});
JPEG XS with Redundant Interfaces
JPEG XS requires exactly 2 input interfaces per media stream for redundancy. Typically one EFA and one ENA interface:
Stack stack;
IRole role;
ISecurityGroup sg1;
ISecurityGroup sg2;
ISubnet subnet;
var efaInterface = VpcInterface.Define(new VpcInterfaceDefineProps {
VpcInterfaceName = "efa-interface",
Role = role,
SecurityGroups = new [] { sg1 },
Subnet = subnet,
NetworkInterfaceType = NetworkInterface.EFA
});
var enaInterface = VpcInterface.Define(new VpcInterfaceDefineProps {
VpcInterfaceName = "ena-interface",
Role = role,
SecurityGroups = new [] { sg2 },
Subnet = subnet,
NetworkInterfaceType = NetworkInterface.ENA
});
var videoStream = MediaStream.Video(new MediaStreamVideo {
MediaStreamId = 1,
MediaStreamName = "video",
VideoFormat = MediaVideoFormat.UHD_2160P,
Fmtp = new FmtpVideo {
ExactFramerate = Framerate.FPS_59_94,
Par = PixelAspectRatio.SQUARE,
Colorimetry = Colorimetry.BT2020,
VideoRange = VideoRange.FULL,
ScanMode = ScanMode.PROGRESSIVE,
Tcs = Tcs.PQ
}
});
var flow = new Flow(stack, "MyJpegXsFlow", new FlowProps {
FlowSize = FlowSize.LARGE_4X, // Required for JPEG XS
VpcInterfaces = new [] { efaInterface, enaInterface },
MediaStreams = new [] { videoStream },
Source = SourceConfiguration.JpegXs(new SourceJpegXs {
FlowSourceName = "jpegxs-source",
MaxSyncBuffer = 100,
MediaStreamSourceConfigurations = new [] { new MediaStreamSourceConfigurationJpegXs {
Encoding = Encoding.JXSV,
Port = 5000,
InputInterface = new [] { efaInterface, enaInterface }, // 2 interfaces for redundancy
MediaStream = videoStream
} }
})
});
Media Streams
Media streams represent individual components of your content (video, audio, ancillary data) for ST 2110 JPEG XS or CDI workflows. Create media streams using the static factory methods and add them to the flow's mediaStreams array:
Stack stack;
// Create media streams
var videoStream = MediaStream.Video(new MediaStreamVideo {
MediaStreamId = 1,
MediaStreamName = "video-stream",
VideoFormat = MediaVideoFormat.HD_1080P,
Fmtp = new FmtpVideo {
Colorimetry = Colorimetry.BT709,
ExactFramerate = Framerate.FPS_29_97,
Par = PixelAspectRatio.SQUARE,
VideoRange = VideoRange.NARROW,
ScanMode = ScanMode.PROGRESSIVE,
Tcs = Tcs.SDR
}
});
var audioStream = MediaStream.Audio(new MediaStreamAudio {
MediaStreamId = 2,
MediaStreamName = "audio-stream",
ChannelOrder = AudioStreamOrderOptions.STANDARD_STEREO
});
// Add to flow
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.Router(),
MediaStreams = new [] { videoStream, audioStream }
});
Audio Channel Order
For audio media streams, use the AudioStreamOrderOptions enum to specify the SMPTE 2110-30 channel order:
// Available channel order options
AudioStreamOrderOptions.MONO; // SMPTE2110.(M)
AudioStreamOrderOptions.DUAL_MONO; // SMPTE2110.(DM)
AudioStreamOrderOptions.STANDARD_STEREO; // SMPTE2110.(ST)
AudioStreamOrderOptions.LTRT_MATRIX_STEREO; // SMPTE2110.(LtRt)
AudioStreamOrderOptions.SURROUND_5_1; // SMPTE2110.(51)
AudioStreamOrderOptions.SURROUND_7_1; // SMPTE2110.(71)
AudioStreamOrderOptions.SURROUND_22_2; // SMPTE2110.(222)
AudioStreamOrderOptions.ONE_SDI_AUDIO_GROUP; // SMPTE2110.(SGRP)
// Example with 5.1 surround
var surroundAudio = MediaStream.Audio(new MediaStreamAudio {
MediaStreamId = 3,
MediaStreamName = "surround-audio",
ChannelOrder = AudioStreamOrderOptions.SURROUND_5_1
});
Media streams can be referenced in source configurations (for CDI and JPEG XS) and output configurations.
Flow Sizes
MediaConnect offers three flow sizes that determine feature support:
| Flow Size | Transport Streams | NDI | CDI / JPEG XS |
|---|---|---|---|
MEDIUM (default) |
β | β | β |
LARGE |
β | β | β |
LARGE_4X |
β | β | β |
This table maps each FlowSize to the capabilities the construct validates. For output counts, throughput limits, and other per-size details, see Flow sizes and capabilities.
The construct validates flow size constraints at synthesis time based on the source protocol and NDI configuration:
MEDIUMsupports transport stream protocols (RTP, SRT, RIST, etc.) but not NDI or CDILARGEsupports transport streams and NDI, and is required when NDI is enabledLARGE_4Xis required for CDI and JPEG XS protocols, and does not support transport streams or NDI
These are mutually exclusive β CDI/JPEG XS and NDI cannot coexist on the same flow because they require different flow sizes.
Stack stack;
VpcInterfaceConfig ndiVpcInterface;
VpcInterfaceConfig efaInterface;
MediaStream videoStream;
// NDI requires LARGE, an encoding profile, and at least one discovery server
// NDI requires LARGE, an encoding profile, and at least one discovery server
new Flow(stack, "NdiFlow", new FlowProps {
FlowSize = FlowSize.LARGE,
NdiConfig = new NdiConfig {
NdiState = State.ENABLED,
NdiDiscoveryServers = new [] { new NdiDiscoveryServerConfig {
DiscoveryServerAddress = "10.0.0.10",
VpcInterface = ndiVpcInterface
} }
},
EncodingConfig = new EncodingConfig {
EncodingProfile = EncodingProfile.CONTRIBUTION_H264_DEFAULT
},
Source = SourceConfiguration.Ndi(new SourceNdi {
FlowSourceName = "ndi-source"
})
});
// CDI and JPEG XS require LARGE_4X
// CDI and JPEG XS require LARGE_4X
new Flow(stack, "CdiFlow", new FlowProps {
FlowSize = FlowSize.LARGE_4X,
VpcInterfaces = new [] { efaInterface },
MediaStreams = new [] { videoStream },
Source = SourceConfiguration.Cdi(new SourceCdi {
FlowSourceName = "cdi-source",
VpcInterface = efaInterface,
Port = 5000,
MaxSyncBuffer = 100,
MediaStreamSourceConfigurations = new [] { new MediaStreamSourceConfigurationCdi {
Encoding = Encoding.RAW,
MediaStream = videoStream
} }
})
});
For more information, see Flow sizes and capabilities.
Gateways
MediaConnect Gateways enable the deployment of on-premises resources for transporting live video to and from the AWS Cloud. Gateways are required for creating bridges.
Creating a Gateway
Stack stack;
var productionNetwork = GatewayNetwork.Define(new GatewayNetworkDefineProps {
CidrBlock = "192.168.1.0/24",
Name = "production-network"
});
var gateway = new Gateway(stack, "MyGateway", new GatewayProps {
GatewayName = "my-gateway",
EgressCidrBlocks = new [] { "10.0.0.0/16" },
Networks = new [] { productionNetwork }
});
Importing an Existing Gateway
Stack stack;
var gateway = Gateway.FromGatewayArn(stack, "ImportedGateway", "arn:aws:mediaconnect:us-west-2:123456789012:gateway:1-XXXXXX");
Bridges
MediaConnect bridges enable you to interconnect on-premises equipment with cloud-based workflows. Bridges support both ingress (on-premises to cloud) and egress (cloud to on-premises) scenarios.
Creating a Bridge
Ingress Bridge (On-premises to Cloud)
An ingress bridge receives content from on-premises equipment and makes it available in the cloud:
Stack stack;
var productionNetwork = GatewayNetwork.Define(new GatewayNetworkDefineProps {
CidrBlock = "192.168.1.0/24",
Name = "production-network"
});
var gateway = new Gateway(stack, "MyGateway", new GatewayProps {
GatewayName = "my-gateway",
EgressCidrBlocks = new [] { "10.0.0.0/16" },
Networks = new [] { productionNetwork }
});
var ingressBridge = new Bridge(stack, "MyIngressBridge", new BridgeProps {
BridgeName = "my-ingress-bridge",
Config = BridgeConfiguration.Ingress(new IngressBridgeConfiguration {
MaxBitrate = Bitrate.Mbps(10),
MaxOutputs = 2,
NetworkSources = new [] { new BridgeNetworkInput {
Name = "on-prem-source",
Source = new BridgeNetworkSource {
Protocol = BridgeProtocol.RTP,
Network = productionNetwork,
MulticastIp = "239.1.1.1",
Port = 5000
}
} }
}),
Gateway = gateway
});
Egress Bridge (Cloud to On-premises)
An egress bridge sends content from MediaConnect flows to on-premises equipment:
Stack stack;
Gateway gateway;
Flow flow;
VpcInterfaceConfig vpcInterface;
GatewayNetwork productionNetwork;
var egressBridge = new Bridge(stack, "MyEgressBridge", new BridgeProps {
BridgeName = "my-egress-bridge",
Config = BridgeConfiguration.Egress(new EgressBridgeConfiguration {
MaxBitrate = Bitrate.Mbps(10),
FlowSources = new [] { new BridgeFlowInput {
Name = "cloud-source",
Source = new BridgeFlowSource {
Flow = flow,
VpcInterface = vpcInterface
}
} },
NetworkOutputs = new [] { new BridgeNetworkOutput {
Name = "on-prem-output",
Output = BridgeOutputConfiguration.Network(new BridgeNetworkOutputProps {
IpAddress = "192.168.1.200",
Port = 5001,
Network = productionNetwork,
Protocol = BridgeProtocol.RTP,
Ttl = 50
})
} }
}),
Gateway = gateway
});
Bridge Sources
For failover scenarios, you can add additional sources to an existing bridge using the BridgeSource construct:
Stack stack;
Bridge bridge;
Flow flow;
// Add a flow source to an egress bridge (requires failover to be enabled)
var additionalSource = new BridgeSource(stack, "AdditionalSource", new BridgeSourceProps {
BridgeSourceName = "backup-source",
Bridge = bridge,
Source = BridgeSourceConfiguration.Flow(new BridgeFlowSource {
Flow = flow
})
});
Bridge Outputs
Bridge outputs are configured as part of the bridge configuration for egress bridges. They define where content exits the bridge to on-premises equipment.
GatewayNetwork productionNetwork;
var networkConfig = BridgeOutputConfiguration.Network(new BridgeNetworkOutputProps {
IpAddress = "192.168.1.200",
Port = 5001,
Network = productionNetwork,
Protocol = BridgeProtocol.RTP,
Ttl = 50
});
IDictionary<string, object> namedOutput = new Dictionary<string, object> { { "name", "on-prem-output" }, { "output", networkConfig } };
Encryption
MediaConnect supports encryption for sources, outputs, and entitlements. This package provides type-safe encryption configuration structs that match the encryption requirements for different protocols.
Encryption Types
MediaConnect supports two types of encryption:
- Static Key Encryption - Used for Zixi Push/Pull protocols and entitlements
- SRT Password Encryption - Used for SRT Listener and SRT Caller protocols
Note: CFN exposes only static-key and srt-password for flow output encryption today; SPEKE is not currently part of the surface.
Auto-created IAM role. Every encryption struct accepts an optional role. Omit it and the consuming construct creates a scoped role for you: trust policy for mediaconnect.amazonaws.com with aws:SourceAccount + aws:SourceArn conditions (confused-deputy protection), and just enough permission to read the provided secret (including kms:Decrypt when the secret uses a customer-managed KMS key).
Providing your own role. If you supply a role, it's used as-is β the construct does not grant it any permissions. You must grant it the necessary permissions yourself. Provide your own role when you need stricter control or a shared identity.
Trust-policy scope: flows vs. routers. When the L2 auto-creates a role, it also pins aws:SourceArn to the consuming resource:
- Flows β the trust policy pins the flow ARN (
arn:...:flow:*:<flow-name>). The*wildcards the service-assigned id segment; the flow name is fixed at create time. - Routers β the trust policy can only pin a wildcarded ARN (
arn:...:routerInput:*/arn:...:routerOutput:*). Router I/O ARNs use a service-generated id segment that is unknown at synth time, and using the live ARN attribute would create a CloudFormation dependency cycle (role β router β role). If you need per-resource pinning, supply your ownrolewith a trust condition that pins the exact ARN β you can compute it from the resource'srouterInputId/routerOutputIdafter first deploy and apply it on a follow-up deploy.
Static Key Encryption
Use a static-key encryption struct for Zixi protocols and entitlements. This requires an encryption algorithm (AES128, AES192, or AES256). Pass it inline where the construct asks for it:
Stack stack;
Flow flow;
IRole role;
ISecret secret;
new FlowEntitlement(stack, "MyEntitlement", new FlowEntitlementProps {
Flow = flow,
Subscribers = new [] { "111122223333" },
Description = "Grant partner access to live feed",
Encryption = new StaticKeyEncryption {
Role = role,
Secret = secret,
Algorithm = EncryptionAlgorithm.AES256
}
});
SRT Password Encryption
SRT protocols take an encryption struct with just role and secret β no algorithm:
Stack stack;
Flow flow;
IRole role;
ISecret secret;
new FlowOutput(stack, "SrtOutput", new FlowOutputProps {
Flow = flow,
Output = OutputConfiguration.SrtCaller(new SrtCallerOutputConfig {
Destination = "203.0.113.100",
Port = 7000,
Encryption = new SrtPasswordEncryption { Role = role, Secret = secret }
})
});
Using Encryption with Sources
Apply encryption when configuring flow sources:
Stack stack;
IRole role;
ISecret secret;
// SRT Listener source with encryption
var flow = new Flow(stack, "MyFlow", new FlowProps {
Source = SourceConfiguration.SrtListener(new SourceSrtListener {
FlowSourceName = "encrypted-source",
Port = 5000,
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24"),
Decryption = new SrtPasswordEncryption { Role = role, Secret = secret }
})
});
// Zixi Push source with encryption
var flow2 = new Flow(stack, "MyFlow2", new FlowProps {
Source = SourceConfiguration.ZixiPush(new SourceZixiPush {
FlowSourceName = "encrypted-zixi-source",
MaxLatency = Duration.Millis(2000),
Network = NetworkConfiguration.PublicNetwork("203.0.113.0/24"),
Decryption = new StaticKeyEncryption {
Role = role,
Secret = secret,
Algorithm = EncryptionAlgorithm.AES256
}
})
});
Using Encryption with Outputs
Apply encryption when configuring flow outputs:
Stack stack;
Flow flow;
IRole role;
ISecret secret;
// SRT Caller output with encryption
var output = new FlowOutput(stack, "EncryptedOutput", new FlowOutputProps {
Flow = flow,
Description = "Encrypted SRT output",
Output = OutputConfiguration.SrtCaller(new SrtCallerOutputConfig {
Destination = "203.0.113.100",
Port = 7000,
Encryption = new SrtPasswordEncryption { Role = role, Secret = secret }
})
});
Using Encryption with Entitlements
Entitlements use static key encryption:
Stack stack;
Flow flow;
IRole role;
ISecret secret;
var entitlement = new FlowEntitlement(stack, "MyEntitlement", new FlowEntitlementProps {
Flow = flow,
Description = "Grant partner access to live feed",
Subscribers = new [] { "111122223333" },
Encryption = new StaticKeyEncryption {
Role = role,
Secret = secret,
Algorithm = EncryptionAlgorithm.AES256
}
});
Router Transit Encryption
When integrating flows with routers, use transit encryption to secure the connection between the flow and router:
Stack stack;
Flow flow;
IRole role;
ISecret secret;
RouterOutput existingRouterOutput;
// Flow output to router with transit encryption
var routerOutput = new FlowOutput(stack, "RouterOutput", new FlowOutputProps {
Flow = flow,
Output = OutputConfiguration.Router(new RouterTransitConfig {
Encryption = new TransitEncryption { Role = role, Secret = secret }
})
});
// Flow source from router with transit encryption
var flowFromRouter = new Flow(stack, "FlowFromRouter", new FlowProps {
Source = SourceConfiguration.Router(new RouterSource {
RouterOutput = existingRouterOutput,
Decryption = new TransitEncryption { Role = role, Secret = secret }
})
});
Router SRT Encryption
Router outputs using SRT protocols use RouterSrtEncryption for encryption:
Stack stack;
RouterNetworkInterface networkInterface;
IRole role;
ISecret secret;
var output = new RouterOutput(stack, "EncryptedSrtOutput", new RouterOutputProps {
RouterOutputName = "encrypted-srt-output",
MaximumBitrate = Bitrate.Mbps(10),
RoutingScope = RoutingScope.REGIONAL,
Tier = RouterOutputTier.OUTPUT_20,
Configuration = RouterOutputConfiguration.Standard(new StandardOutputConfigurationProps {
Protocol = RouterOutputProtocol.SrtCaller(new SrtCallerOutputProtocolProps {
DestinationAddress = "203.0.113.100",
DestinationPort = 9001,
MinimumLatency = Duration.Millis(200),
EncryptionConfiguration = new RouterSrtEncryption { Role = role, Secret = secret }
}),
NetworkInterface = networkInterface
})
});
Note: RouterSrtEncryption is distinct from SrtPasswordEncryption (used on flow sources/outputs) β router outputs use a simpler CFN shape without a keyType discriminator.
CloudWatch Metrics
Flows and Bridges expose CloudWatch metric helpers for monitoring. You can create alarms and dashboards using these metrics:
Flow flow;
Stack stack;
// Create a CloudWatch alarm on source bitrate
var alarm = flow.MetricSourceBitrate().CreateAlarm(stack, "LowBitrate", new CreateAlarmOptions {
Threshold = 1000000,
EvaluationPeriods = 1
});
// Monitor unrecovered packets
flow.MetricSourceNotRecoveredPackets().CreateAlarm(stack, "PacketLoss", new CreateAlarmOptions {
Threshold = 100,
EvaluationPeriods = 2
});
// Track total packets with custom options
var totalPackets = flow.MetricSourceTotalPackets(new MetricOptions {
Statistic = "sum",
Period = Duration.Minutes(5)
});
Flow metrics
metricSourceBitrate()- Bitrate of content ingested into the flow (average)metricSourceNotRecoveredPackets()- Packets lost in transit that were not recovered by error correction (sum)metricSourceTotalPackets()- Total packets received by the flow sources (sum)metricSourceSelected()- Indicates which source is being used under Failover mode (max; 1 = active, 0 = standby)metricSourceConnected()- Source connection state for Zixi, SRT, and RIST (min; 1 = connected, 0 = disconnected)metricSourceDisconnections()- Number of times the source transitioned from connected to disconnected (sum)metricSourceDroppedPackets()- Packets lost before any error correction took place (sum)metricSourcePacketLossPercent()- Percentage of packets lost during transit, even if they were recovered (average)metricSourceRoundTripTime()- Round-trip time to the source for RIST, Zixi, and SRT (average, milliseconds)metricSourceJitter()- Current network jitter of the source (average, milliseconds)metric(metricName)- Create a custom metric by name
Bridge metrics
Bridge metrics are dimensioned by BridgeARN. The underlying CloudWatch metric name is chosen automatically based on whether the bridge is ingress or egress.
metricSourceBitrate(bridgeSourceName)- Bitrate of a specific bridge source (average)metricSourcePacketLossPercent(bridgeSourceName)- Percentage of packets lost on a specific bridge source (average)metricFailoverSwitches()- Total number of times the bridge switches between sources underFAILOVERfailover mode (sum)metric(metricName)- Create a custom metric by name
Router Input metrics
Router input metrics are dimensioned by RouterInputARN.
metricBitrate()- Bitrate of the router input's payload (average)metricNotRecoveredPackets()- Packets lost in transit that were not recovered by error correction (sum)metricTotalPackets()- Total number of packets received by the router input (sum)metricConnected()- Connection state for SRT sources (min; 1 = connected, 0 = disconnected)metricContinuityCounterErrors()- Continuity counter errors in the transport stream (sum)metricLatency()- Recovery latency of the input stream for RIST, SRT, and RTP-FEC (average, milliseconds)metricFailoverSwitches()- Total times the router input switched sources under Failover mode (sum)metric(metricName)- Create a custom metric by name
Router Output metrics
Router output metrics are dimensioned by RouterOutputARN.
metricBitrate()- Bitrate of the router output's payload (average)metricTotalPackets()- Total number of packets sent by the router output (sum)metricConnected()- Connection state for SRT outputs (min; 1 = connected, 0 = disconnected)metricArqRequests()- Retransmitted packets requested through ARQ for RIST and SRT outputs (sum)metric(metricName)- Create a custom metric by name
Gateway metrics
Gateway metrics are dimensioned by GatewayARN. Pass extra dimensions such as NetworkName, InstanceId, or BridgeSourceName via props.dimensionsMap to narrow to a specific network, appliance, or bridge source.
metricEgressBridgeTotalPackets()- Total packets sent from egress bridges hosted on the gateway (sum)metricEgressBridgeDroppedPackets()- Packets dropped by egress bridges hosted on the gateway (sum)metricIngressBridgeTotalPackets()- Total packets received by ingress bridges hosted on the gateway (sum)metricIngressBridgeDroppedPackets()- Packets dropped by ingress bridges hosted on the gateway (sum)metric(metricName)- Create a custom metric by name (e.g.IngressBridgeBitRate,EgressBridgeBitRate,IngressBridgeSourcePacketLossPercent)
Pair the total + dropped helpers to build a dropped-packet percentage chart β for example, divide metricEgressBridgeDroppedPackets() by metricEgressBridgeTotalPackets() in a math expression.
All metrics support standard CloudWatch metric options for customizing period, statistic, and dimensions.
Public CIDR warnings
Several constructs accept CIDR ranges that determine who can contribute content or pull outputs. Passing an open range (0.0.0.0/0 or any /0 prefix) makes the resource reachable from anywhere on the public internet, which is rarely what you want. The module emits synthesis-time warnings when it detects an open range on:
GatewayProps.egressCidrBlocksNetworkConfiguration.publicNetwork(cidr)used on flow sourcescidrAllowListon Zixi Push / Zixi Pull / SRT Listener flow outputsRouterNetworkConfiguration.publicNetwork({ cidr })
Restrict each range to the narrowest set of addresses that actually need access.
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.