awslabs / amazon-kinesis-video-streams-webrtc-sdk-android

Android SDK for interfacing with Amazon Kinesis Video Streams Signaling Service.
Apache License 2.0
58 stars 37 forks source link

AWS kinesis consumer demo request for android. #11

Closed JeetSA closed 4 years ago

JeetSA commented 4 years ago

Is there any way to show video stream from AWS kinesis server to mobile application specific for android?

What am I trying to achieve is, there is a hardware device which is having a camera. I want to live stream from that hardware device to android mobile application using AWS kinesis service.

How can I get a stream URL from kinesis SDK in android?

I have gone through the kinesis documentation for android, which is having details for recording and sending the stream from mobile device to AWS server. The link is as follow:

https://aws-amplify.github.io/docs/sdk/android/analytics

If anyone has done something like that, can you please help me with that?

Thanks.

zhiyua-git commented 4 years ago

Hi @JeetSA ,

Can you elaborate more on your use case? Are you asking for a realtime playback through WebRTC or video cloud storage & playback? What OS is running on your hardware device with camera? Are you trying to live stream from that hardware device to Kinesis Video and then play it back on Android App? Are you able to install Kinesis Video producer SDK on the hardware device?

Depending on the use cases, the solutions would be different.

Thanks.

JeetSA commented 4 years ago

Hi @zhiyua-git ,

Thanks for replying.

Are you asking for a realtime playback through WebRTC or video cloud storage & playback?

What OS is running on your hardware device with camera?

Are you trying to live stream from that hardware device to Kinesis Video and then play it back on Android App?

JeetSA commented 4 years ago

@zhiyua-git Can you please let me know that when can I expect any update? It would be a great help.

Thanks.

zhiyua-git commented 4 years ago

Hi @JeetSA ,

Your use case requires playback on Android App. You can use the Android SDK to call getHLSStreamingSessionURL API to retrieve an HLS streaming URL for playback. Check details about Kinesis Video HLS playback here.

You can use players like Exoplayer to play that HLS streaming URL that supports HLS playback on Android platform. Please note the URL has expiration time that you might want to extend or refresh. Thanks.

JeetSA commented 4 years ago

Hi @zhiyua-git

Thank you for reverting back.

I am not able to find getHLSStreamingSessionURL method when I am trying to import kinesis dependency. That method is in under "com.amazonaws.services.kinesisvideoarchivedmedia" package. I am not able to find that package too. The error is Unresolved reference.

Can you please help me with that?

zhiyua-git commented 4 years ago

Hi @JeetSA ,

You need to add this to your build grade to load dependency on kinesis video archived media client. implementation ("com.amazonaws:aws-android-sdk-kinesisvideoarchivedmedia:2.16.8@aar") { transitive = true }

JeetSA commented 4 years ago

Hi @zhiyua-git

I added the dependency implementation ("com.amazonaws:aws-android-sdk-kinesisvideoarchivedmedia:2.16.8@aar") { transitive = true }. However I am not able to build the project with the same. I am getting the error as follow.

ERROR: Failed to resolve: com.amazonaws:aws-android-sdk-kinesisvideoarchivedmedia:2.16.8

Can you please help me with that?

zhiyua-git commented 4 years ago

Hi @JeetSA ,

Can you try change version from 2.16.8 to 2.14.+? I got the version from AWS Android sdk repo and maybe it is too new to be in published version.

JeetSA commented 4 years ago

Hi @zhiyua-git ,

I changed the version 2.16.8 to 2.14.+. However I am not able to build the project with the same. The error is as follow:

ERROR: Failed to resolve: com.amazonaws:aws-android-sdk-kinesisvideoarchivedmedia:2.14.+

zhiyua-git commented 4 years ago

Hi @JeetSA ,

Please use com.amazonaws:aws-android-sdk-kinesisvideo-archivedmedia instead of com.amazonaws:aws-android-sdk-kinesisvideoarchivedmedia. First one loads.

JeetSA commented 4 years ago

Hello @zhiyua-git ,

Now I am able to build the project with implementation ("com.amazonaws:aws-android-sdk-kinesisvideo-archivedmedia:2.16.8") { transitive = true }. Now I will try to get the Stream URL from AWSKinesisVideoArchivedMedia class.

Thank you so much for your help and support. :)

JeetSA commented 4 years ago

Hello @zhiyua-git

I have implemented the code for getting the session HLS URL for live streaming. The code is as follow:

val provider = object : AWSCredentialsProvider{
                    override fun getCredentials(): AWSCredentials {
                       return object : AWSCredentials {
                           override fun getAWSAccessKeyId(): String {
                               return "xxxxxxxxxx"
                           }

                           override fun getAWSSecretKey(): String {
                               return "xxxxxxxxxxx"
                           }
                       }
                    }

                    override fun refresh() {

                    }

                }
val client = AWSKinesisVideoArchivedMediaClient(provider)
client.setRegion(Region.getRegion(Regions.AP_SOUTH_1))
val request = GetHLSStreamingSessionURLRequest().withStreamName("stream_name").apply {
                    streamARN = "arn:aws:kinesisvideo:ap-south-1:535693658748:stream/stream_name/1581494584992"
                    discontinuityMode = DiscontinuityMode.ALWAYS.toString()
                    hlsFragmentSelector = HLSFragmentSelector().apply {
                        fragmentSelectorType = FragmentSelectorType.SERVER_TIMESTAMP.toString()
                    }
                    expires = 1000
                    playbackMode = PlaybackMode.LIVE.toString()
                }
STREAM_URL = client.getHLSStreamingSessionURL(request).hlsStreamingSessionURL

However I am facing an error like:

com.amazonaws.AmazonClientException: Unable to unmarshall error response (Unable to parse JSON String.). Response Code: 403, Response Text: Forbidden, Response Headers: {X-Android-Selected-Protocol=http/1.1, x-amzn-RequestId=b1f94828-2118-44b0-8f30-994d99ee61b0, X-Android-Response-Source=NETWORK 403, X-Android-Sent-Millis=1581944863557, Content-Length=130, X-Android-Received-Millis=1581944863611, Date=Mon, 17 Feb 2020 13:07:45 GMT}

I did not find any demo related to this so I am not sure if there is any thing missing. Can you please help me?

Thanks.

zhiyua-git commented 4 years ago

Hi @JeetSA ,

You response is 403 Forbidden, this means you don't have permission for the operation, it can be either your AccessKeyId and SecretKey is wrong, say putting only AccessKeyId and SecretKey while not inputing SessionToken for a temporary AWS credentials, or your IAM role of this AccessKeyId/SecretKey doesn't have permission for calling GetHLSStreamingSessionURL.

I don't see anything from your code directly that can cause a 403. @MixMasterMitch might have some suggestion. Thanks.

JeetSA commented 4 years ago

@MixMasterMitch

I have allowed the permission for GetHLSStreamingSessionURL on AWS console. I have given the full access to AWS kinesis video stream. However I am still getting the same error as follow:

com.amazonaws.AmazonClientException: Unable to unmarshall error response (Unable to parse JSON String.). Response Code: 403, Response Text: Forbidden, Response Headers: {X-Android-Selected-Protocol=http/1.1, x-amzn-RequestId=b1f94828-2118-44b0-8f30-994d99ee61b0, X-Android-Response-Source=NETWORK 403, X-Android-Sent-Millis=1581944863557, Content-Length=130, X-Android-Received-Millis=1581944863611, Date=Mon, 17 Feb 2020 13:07:45 GMT}

Can you please help me?

Thanks.

MixMasterMitch commented 4 years ago

It looks like you have not set the data endpoint for the AWSKinesisVideoArchivedMediaClient. See:

zhiyua-git commented 4 years ago

Hi @JeetSA ,

Have you got it working or not? Closing the issue as it is not replied for ~1 month, feel free to reopen if your issue persists.