can we pass the username in videocore library for RTMP URL?

435 Views Asked by At

I am making an app based on broadcasting I am using videoCore Lib for Broadcast for that I am using below code to start rtmp session

  [_session startRtmpSessionWithURL:urlForStream
                                     andStreamKey:streamID];

urlForStream is url of wowza server like rtmp://some.tv/some/username/username/randamvalue that Randam value is don't want to override my videos every time so i am using that url and now My Problem is VCSessionState class state is not changing it is not coming to started state and I am getting the Error here is streamsessio.mm class and [NSRL(m_runLoop) run]; i don't kow where i miss please help me out

1

There are 1 best solutions below

5
On

Considering from my experience of having created my own RTMP protocol library, I thought you have to separate the URL into two parts: tcUrl and stream key. In your case, the random value is likely to be a stream key.

NSString *tcUrl;
NSString *stream;
separateRtmpUrl(urlForStream, &tcUrl, &stream);
[_session startRtmpSessionWithURL:tcUrl andStreamKey:stream];

The definition of the separateRtmpUrl function can be like this.

static void separateRtmpUrl(NSString *baseUrl, NSString **tcUrl, NSString **stream)
{
    NSURL *url = [NSURL URLWithString:baseUrl];
    *stream = url.pathComponents.lastObject;
    *tcUrl  = [NSString stringWithFormat:@"%@://%@%@", url.scheme, url.host,
               [NSString pathWithComponents:
                [url.pathComponents subarrayWithRange:
                 NSMakeRange(0, url.pathComponents.count - 1)]]];

    if (url.query) {
        *stream = [@[*stream , url.query] componentsJoinedByString:@"?"];
        *tcUrl  = [@[*tcUrl  , url.query] componentsJoinedByString:@"?"];
    }
}