i writing rtsp code using libcurl https://curl.haxx.se/libcurl/c/rtsp.html.
i wrote signal handler catch ctrl+c , teardown curl/uri close session while playing.
i got error message - " curl_easy_perform() failed: failed initialization " had initialized curl in main function.
====== code section ========
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include <signal.h>
curl *curl;
char *uri ;
static void rtsp_teardown(curl *curl, const char *uri)
{
curl_easy_setopt(curl, curlopt_rtsp_request, (long)curl_rtspreq_teardown);
curl_easy_perform(curl);
}
void sighand(int signo){
switch(signo){
case sigquit:
rtsp_teardown(curl,uri);
}
}
void signal(){
struct sigaction actions;
memset(&actions, 0, sizeof(actions));
sigemptyset(&actions.sa_mask);
actions.sa_flags = 0;
actions.sa_handler = sighand;
signal(sigquit, sighand);
}
/*
rtsp option,describe .. found url above.
*/
int main()
{
/*
initial variable found url above
*/
signal();
curl_global_init(curl_global_all);
curl = curl_easy_init();
if(curl != null) {
rtsp_options(curl, uri);
rtsp_describe(curl, uri);
rtsp_setup(curl, uri, transport);
rtsp_play(curl, uri, range);
}
return 0;
}
========================
hmm looks of code the code should "fall through" speak, there nothing waits after rtsp_play() (unless you've inside routine prevents return). sigquit called after ctrl+\, ctrl+c sends sigint link
besides check pointer null practice (in signal handler in case check if still valid pointer).
Comments
Post a Comment