EricssonResearch / openwebrtc-ios-sdk

SDK for adding OpenWebRTC to your iOS apps using CocoaPods
BSD 2-Clause "Simplified" License
69 stars 37 forks source link

Best approach to setup one-way video without local sources #15

Open zombieobject opened 9 years ago

zombieobject commented 9 years ago

My objective only receive remote sources in a native iOS application.

It appears that I must use the following in order to start receiving video.

- (void)startGetCaptureSourcesForAudio:(BOOL)audio video:(BOOL)video;

Even overriding this implementation to send a media type of OWR_MEDIA_TYPE_UNKOWN and commenting out the subsequent g_assert in got_local_sources() fails to move forward with receiving video. At this point, I gather I'm going down the wrong path.

What's my best approach to stripping this down to one remote source?

Cheers ~

zombieobject commented 9 years ago

Actually, I missed a step after commenting out the g_assert in got_local_sources for OpenWebRTCNativeHandler and that does move me onward to receiving the remote source video. It still feels like I'm heading down the wrong path by calling this.

Suggestions, pointers welcome. :D

zombieobject commented 9 years ago

I think I've found the right direction. I added a startSession method that achieves my goal. I'll paste here to confirm I'm not doing something too crazy. :D

- (void)startSesssion
{

    transport_agent = owr_transport_agent_new(FALSE);

    for (NSDictionary *server in staticSelf.helperServers) {
        owr_transport_agent_add_helper_server(transport_agent,
                                              (OwrHelperServerType)[server[@"type"] intValue],
                                              [server[@"address"] UTF8String],
                                              [server[@"port"] intValue],
                                              [server[@"username"] UTF8String],
                                              [server[@"password"] UTF8String]);
    }

    // Handle cached remote candidates.
    @synchronized (staticSelf.remoteCandidatesCache) {
        [staticSelf.remoteCandidatesCache enumerateObjectsUsingBlock:^(NSDictionary *candidate, NSUInteger idx, BOOL *stop) {
            [staticSelf handleRemoteCandidateReceived:candidate];
        }];
        [staticSelf.remoteCandidatesCache removeAllObjects];
    }
}

Cheers ~

zombieobject commented 9 years ago

If I'm heading down the right path, I'll clean it up by updating - (void)startGetCaptureSourcesForAudio:(BOOL)audio video:(BOOL)video; to use OWR_MEDIA_TYPE_UNKOWN in the case of a double NO and subsequently update static void got_local_sources(GList *sources) to be aware of this type and submit a pull request.

The method signature of - (void)startGetCaptureSourcesForAudio:(BOOL)audio video:(BOOL)video; could be changed to be more of a generic selector as well.

Potentially: -(void)startSessionForAudio:(BOOL)audio video:(BOOL)video; thus removing the "capture" language.

stefanalund commented 9 years ago

@zombieobject I think that is a good suggestion. Please submit a PR when ready, thanks!

stefanalund commented 9 years ago

How's it going?

evermeer commented 9 years ago

I only changed that what you mentioned in your first comment. (change to startGetCaptureSourcesForAudio and remove the g_assert) and that seems to function. I do receive a remote video without sending something myself.

So i wonder: What was the missed step?

I see that you added the startSession as an alternative to got_local_sources but then without handling the sources. Wouldn't it be easier to just add a check for sources in the got_local_sources?

byhkalo commented 9 years ago

Hi. I need in one-way video (only recieve). I have the last version of OpenWebRTC-SDK. So I use this method in case: [nativeHandler startGetCaptureSourcesForAudio:NO video:NO];

In my log only: GLib-CRITICAL _: g_main_context_push_thread_default: assertion 'acquired_context' failed GLib-CRITICAL _: g_main_context_pop_thread_default: assertion 'stack != NULL' failed

After [nativeHandler initiateCall] in log only:

can_send_offer

Nothing more. nativeHandler doesn't generating offer. Nothing happen. I tested it in NativeDemo app (with http://demo.openwebrtc.io:38080/ pair). In my application the same problem.

P.S. if I initiate call from site or other devise with [nativeHandler startGetCaptureSourcesForAudio:NO video:YES]; everything working good. I have one-way video streaming on my first devise

superdump commented 9 years ago

Perhaps some modifications are going to be needed to allow for the receive only case. The iOS SDK is not as developed and flexible as the Android SDK. Hopefully it can be synchronised.