Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Accessing audio stream response . #7

Closed
baali opened this issue May 5, 2017 · 3 comments
Closed

Accessing audio stream response . #7

baali opened this issue May 5, 2017 · 3 comments

Comments

@baali
Copy link

baali commented May 5, 2017

Hello,
This might be something very trivial which I am overlooking or missing alltogether. Based on Integrattion tests AlexaDirectiveSequencerLibraryTest.cpp I am trying to put together code where I can playback the audio response from AVS:

    std::string payloadUrl;
    jsonUtils::lookupStringValue(directive->getPayload(), "url", &payloadUrl);
    auto stringIndex = payloadUrl.find(":");
    auto contentId = payloadUrl.substr(payloadUrl.find(':') + 1);
    auto attachmentReader = directive->getAttachmentReader(contentId);
    auto status = attachmentReader.wait_for(WAIT_FOR_TIMEOUT_DURATION);

After this step, I am not sure how to get to Audio Payload. I have looked at AttachmentManager.h and ACL/include/ACL/AttachmentManagerInterface.h but still couldn't figure out how to use this attachmentReader to get Audio Stream.

@lrvega
Copy link

lrvega commented May 5, 2017

After attachmentReader.wait_for(WAIT_FOR_TIMEOUT_DURATION); returns, and status == std::future_status::read, then just do the following std::shared_ptr<std::iostream> attch = attachmentReader.get(); If the stream is good, it's readable.

@baali
Copy link
Author

baali commented May 5, 2017

Thank you for the prompt reply. The status has to be ready instead of read. I have been tinkering around to see if I can read it but with attch.get()->gcount(), attch.get()->tellg() I am getting 0. I am trying different operators from http://en.cppreference.com/w/cpp/io/basic_istream read, >> etc, but haven't got them to work.

@baali
Copy link
Author

baali commented May 6, 2017

Got it, I had to read the buffer(attch->rdbuf()) and that worked. Thank you.

@baali baali closed this as completed May 6, 2017
@baddemiya baddemiya mentioned this issue Feb 17, 2018
2 tasks
@adeb adeb mentioned this issue Apr 8, 2018
6 tasks
@xuqifu xuqifu mentioned this issue Jul 12, 2018
6 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants