Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kinesis video putmedia for iOS #2382

Closed
PaulIPS opened this issue Mar 24, 2020 · 8 comments
Closed

Kinesis video putmedia for iOS #2382

PaulIPS opened this issue Mar 24, 2020 · 8 comments
Labels
bug Something isn't working follow up Requires follow up from maintainers kinesis video Issues related to Kinesis Video

Comments

@PaulIPS
Copy link

PaulIPS commented Mar 24, 2020

State your question
Hi how do you do a put media request to Kinesis using the iOS SDK?. I can't seam to find any reference code after getting the endpoint URL from getDataEndpoint.

I see in the android SDK there is a PutMediaClient.builder() but I can't seam to find something similar in the iOS SDK.

Which AWS Services are you utilizing?
Kinesis Video

Environment:

  • SDK Version: 2.13
  • Dependency Manager: Cocoapods
  • Swift Version : 4.0

Device Information:

  • Device: iPad
  • iOS Version: 13.1.3
@wooj2 wooj2 added question General question documentation Documentation improvements labels Mar 25, 2020
@wooj2
Copy link
Contributor

wooj2 commented Mar 25, 2020

Hi @PaulScala,

Thanks for reaching out. I'm not super familiar with this part of the SDK, but it seems like there is a unit tests here named "testGetHlsStreamingSessionUrl"

func testGetHlsStreamingSessionUrl() {

Perhaps changing line 84 from:

getDataEndpointRequest?.apiName = AWSKinesisVideoAPIName.getHlsStreamingSessionUrl

to something like:

            getDataEndpointRequest?.apiName = AWSKinesisVideoAPIName.putMedia

might be what you're looking for?

@wooj2 wooj2 added the pending-community-response Issue is pending response from the issue requestor label Mar 25, 2020
@PaulIPS
Copy link
Author

PaulIPS commented Mar 25, 2020

@wooj2 Thank you for the suggestion.

The problem is kvClient.getDataEndpoint() just returns a url string. I can't seam to find any methods in the iOS SDK related to actually pushing data to that URL.

Here is the object the API returns:

@interface AWSKinesisVideoGetDataEndpointOutput : AWSModel

/**
 <p>The endpoint value. To read data from the stream or to write data to it, specify this endpoint in your application.</p>
 */
@property (nonatomic, strong) NSString * _Nullable dataEndpoint;

@end

@wooj2
Copy link
Contributor

wooj2 commented Mar 28, 2020

Hey @PaulScala ,

I checked around with people more familiar with this area, and they said that there is currently no easy way to support this at the moment.

They suggested two potential options with moving forward:

  1. You could use the iOS AWS mobile SDK components to get the endpoint and then use custom logic to get the frames from the camera/device, encode it, package it into MKV and use a NSURL type of client to issue SigV4 signed request to PutMedia directly.

  2. You can attempt to compile the C Producer SDK for iOS and use everything natively: https://github.com/awslabs/amazon-kinesis-video-streams-producer-c
    In this case you'd still be responsible for retrieving the frames from the device and encoding them.

Option one seems to be very involved, and it seems like option 2 does some of the heavy lifting for you.

Best of luck!

@PaulIPS
Copy link
Author

PaulIPS commented Mar 30, 2020

Hi @wooj2 Thank you for following up on this. It looks like option 1 would be the best path forwards for us. Does the AWS iOS SDK have anything I can leverage for helping make a SigV4 request, or is it best to make my own REST layer.

@wooj2 wooj2 added the kinesis video Issues related to Kinesis Video label Mar 30, 2020
@wooj2
Copy link
Contributor

wooj2 commented Mar 30, 2020

Hey @PaulScala ,

As part of AWSCore, there is AWSSignature which I believe should be of some help:
https://github.com/aws-amplify/aws-sdk-ios/blob/master/AWSCore/Authentication/AWSSignature.h

@PaulIPS
Copy link
Author

PaulIPS commented Apr 1, 2020

Hey @wooj2 So I have been digging into the AWS core SDK trying to implement this, and I got a bit stuck.

My understanding is that to load data into a web request you need to use a request sterilizer. Since none of the request serializes take a data object in I have to create my own:

class AWSRawRequestSerializer: NSObject, AWSURLRequestSerializer {
    var data : Data
    
    init(data: Data) {
        self.data = data
    }
    
    func validate(_ request: URLRequest!) -> AWSTask<AnyObject>! {
        return AWSTask(result: nil)
    }
    
    func serializeRequest(_ request: NSMutableURLRequest!, headers: [AnyHashable : Any]!, parameters:
        [AnyHashable : Any]!) -> AWSTask<AnyObject>! {
        
        if headers != nil {
            for (key, value) in headers {
                request.addValue(value as! String, forHTTPHeaderField: key as! String)
            }
        }
        
        request.httpBody = self.data
        return AWSTask(result: nil)
    }
}

The problem I am having is when I set request.httpBody I then get back The request signature we calculated does not match the signature you provided .

any idea what I am missing? When I step step through the request the method signRequestV4 is being hit inside AWSSignature.

@palpatim palpatim removed the pending-community-response Issue is pending response from the issue requestor label May 1, 2020
@drochetti drochetti added the follow up Requires follow up from maintainers label Oct 20, 2020
@ShahinOskouie
Copy link

Any updates on this topic? I have the same issue!

@harsh62 harsh62 added bug Something isn't working and removed documentation Documentation improvements question General question labels May 9, 2023
@atierian
Copy link
Member

atierian commented Dec 6, 2023

Thanks for opening this feature request. We don't plan on adding support for PutMedia at this time.

@atierian atierian closed this as completed Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working follow up Requires follow up from maintainers kinesis video Issues related to Kinesis Video
Projects
None yet
Development

No branches or pull requests

7 participants