What metadata of a kinesis video stream (from amazon connect) will tell if the chunk / fragment is AUDIO_TO_CUSTOMER or AUDIO_FROM_CUSTOMER?

  Kiến thức lập trình

When you enable “Live media streaming” in amazon connect, the call audio will be streamed in real time to a Kinesis video stream and you can consume the stream using boto3 “get_data_endpoint” and “.get_media()” APIs.

When i start to consume the stream, i cannot figure out if it is the audio_to_customer or audio_from_customer.

I have found a Java library that does exactly this, however it uses another Java Library. It gets quite complicated from there and i don’t know Java much.

from src/main/java/software/aws/connect/LMSDataVisitor.java:

if (MkvTypeInfos.SIMPLEBLOCK.equals(dataElement.getElementMetaData().getTypeInfo())) {
final MkvValue frame = dataElement.getValueCopy();

        final ByteBuffer frameBuffer = frame.getVal().getFrameData();
        final String trackName  = fragmentMetadataVisitor.getMkvTrackMetadata(frame.getVal().getTrackNumber()).getTrackName();
        try {
            byte[] frameBytes = new byte[frameBuffer.remaining()];
            if (Strings.isNullOrEmpty(trackName) || "AUDIO_FROM_CUSTOMER".equals(trackName)) {
            } else if ("AUDIO_TO_CUSTOMER".equals(trackName)) {
            } else {
            // Unknown track name. Not writing to output stream.

As i write my application in python, I cannot utilize the original library they used. There is another python library that is similar but I couldn’t figure out how to get if it is audio_from_customer or audio_to_customer.

P.S: this is my first time asking a question, and please let me know what other information you need and I will add them. TIA

New contributor

Kay c is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.