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년 전435회 조회
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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠