AWS C++ SDK GetMedia call with Live KVS stream

1

I am currently working on implementing a C++ project to retrieve the most up to date fragment from a Live KVS Stream using GetMedia. However whenever GetMedia is called, the program will currently hang at that point until the stream has been stopped, only after this will the GetMedia call return some data.

My question is: Is there a way to retrieve the latest fragment in a stream using GetMedia, while the stream is active and live streaming from a Pi 4. Without having to stop the stream?

My Current Code is the following, please let me know if there is anything I am missing or ways I could improve or solve this issue

Aws::SDKOptions options;
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Info;
    Aws::InitAPI(options);
    {
        Aws::Auth::AWSCredentials aws_credentials;
        aws_credentials.SetAWSAccessKeyId("MY_ACCESS_KEY");
        aws_credentials.SetAWSSecretKey("MY_SECRET_KEY");
        Aws::Auth::SimpleAWSCredentialsProvider provider = Aws::Auth::SimpleAWSCredentialsProvider(aws_credentials);

        Aws::Client::ClientConfiguration clientConfig;
        clientConfig.region = Aws::Region::EU_WEST_1;

        Aws::KinesisVideo::KinesisVideoClient client = Aws::KinesisVideo::KinesisVideoClient(aws_credentials, clientConfig);
        Aws::KinesisVideo::Model::GetDataEndpointRequest request;
        request.SetStreamName("MY_STREAM_NAME");
        request.SetAPIName(Aws::KinesisVideo::Model::APIName::GET_MEDIA);
        
        Aws::KinesisVideo::Model::GetDataEndpointOutcome result = client.GetDataEndpoint(request);
        cout << result.GetError().GetExceptionName() + ": " + result.GetError().GetMessage() << endl;
        cout << result.GetResult().GetDataEndpoint() << endl;
        cout << "GetDataEndpoint successful: " << result.IsSuccess() << endl;


        Aws::KinesisVideoMedia::KinesisVideoMediaClient* videoMediaClient = new Aws::KinesisVideoMedia::KinesisVideoMediaClient(aws_credentials, clientConfig);
        Aws::KinesisVideoMedia::Model::GetMediaRequest getMediaRequest;
        getMediaRequest.SetStreamName("MY_STREAM_NAME");

        Aws::KinesisVideoMedia::Model::StartSelector selector;
        selector.WithStartSelectorType(Aws::KinesisVideoMedia::Model::StartSelectorType::NOW);
        getMediaRequest.SetStartSelector(selector);

        videoMediaClient->OverrideEndpoint(result.GetResultWithOwnership().GetDataEndpoint());
        videoMediaClient->EnableRequestProcessing();
        videoMediaClient->SetServiceClientName("kinesisvideo");

        Aws::KinesisVideoMedia::Model::GetMediaOutcome outcome = client->GetMedia(request);
        if (outcome.IsSuccess()) {
            cout << "Success" << endl;
            char buffer[1024];
            outcome.GetResultWithOwnership().GetPayload().read(buffer, 1024);
            cout << buffer<< endl;
        } else {
            cout << "Failure" << endl;
        }
    }
    ShutdownAPI(options);
asked 2 years ago426 views
2 Answers
0

Hi, this is Jorge and thanks for using this channel to discuss the issue. From my internal discussion with the KVS service team you should proceed and create a ticket with AWS if you have a support contract. If not, this id the best guidance I can provide to you;

GetMedia can be called with the start selector NOW to start reading from the latest chunk i.e tip of the ingested data. -> https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_dataplane_StartSelector.html#term Can you please help us with the exact setup (what SDK version you are using, etc.) and first reproduce the scenario. We do not have access to reproduce this on a raspberry pi device. We recommend you to repro on any linux machine.

Looking forward for your feedback on this query.

AWS
answered 2 years ago
0

We are having the same issue, tried on Ubuntu 20.04 and Mac OS Sanoma with the latest SDK of cpp. Any help from KVS team is appreciated.

answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions