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);
已提问 2 年前434 查看次数
2 回答
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
已回答 2 年前
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.

已回答 2 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则