{Looks bad in comment, put it here}
Apple says network.framework is better than OpenSSL+Socket, I have problem in proving that, anyone has official way of receiving the data?
void handleIncomingVideo( void* caller, nw_connection_t connection = nullptr )
{
// init processing
...
//handle incoming data
nw_connection_receive(
connection,
1,
bufLen,
^( dispatch_data_t content,
nw_content_context_t context,
bool is_complete,
nw_error_t receive_error ) {
auto isBufferBeginWithStartCode = []( const char* frame ) -> bool {
return ( frame[0] == 0x00 && frame[1] == 0x00 && frame[2] == 0x00 && frame[3] == 0x01 );
};
if (is_complete && content == nil) {
loggerEx(LOG_INFO, "Receiver done with video data!");
return;
}
if ( content != nullptr )
{
// handle received data here
....
// 2. schedule next incoming video recv
nw_retain( connection );
handleIncomingVideo( caller, connection );
}
else
{
// Context is nullptr, schedule the next recv
if ( receive_error == nullptr )
{
nw_retain( connection );
handleIncomingVideo( caller, connection );
}
}
} );
The video quality is not as stable as my old openssl + socket client, the same video(H264 stream) server, mostly the video quality is as expected, but sometime the video is blocky(missing data, not network issue since never happen with openssl+socket client), and sometime there is no video data come in, while old openssl+socket doesn't have this issue.
Am I using it correct?
Topic:
App & System Services
SubTopic:
Networking
Tags: