Mercurial > mplayer.hg
comparison stream/librtsp/rtsp.c @ 27103:a3f6dc43b585
Move rtsp_close away by simplification - avoids symbol clash with libnemesi
author | lu_zero |
---|---|
date | Wed, 25 Jun 2008 09:53:45 +0000 |
parents | 64d82a45a05d |
children | 83d160a30ca7 |
comparison
equal
deleted
inserted
replaced
27102:7acfd8c9c3bb | 27103:a3f6dc43b585 |
---|---|
573 */ | 573 */ |
574 | 574 |
575 //rtsp_t *rtsp_connect(const char *mrl, const char *user_agent) { | 575 //rtsp_t *rtsp_connect(const char *mrl, const char *user_agent) { |
576 rtsp_t *rtsp_connect(int fd, char* mrl, char *path, char *host, int port, char *user_agent) { | 576 rtsp_t *rtsp_connect(int fd, char* mrl, char *path, char *host, int port, char *user_agent) { |
577 | 577 |
578 rtsp_t *s=malloc(sizeof(rtsp_t)); | 578 rtsp_t *s; |
579 int i; | 579 int i; |
580 | 580 |
581 if (fd < 0) { | |
582 mp_msg(MSGT_OPEN, MSGL_ERR, "rtsp: failed to connect to '%s'\n", host); | |
583 return NULL; | |
584 } | |
585 | |
586 s = malloc(sizeof(rtsp_t)); | |
587 | |
581 for (i=0; i<MAX_FIELDS; i++) { | 588 for (i=0; i<MAX_FIELDS; i++) { |
582 s->answers[i]=NULL; | 589 s->answers[i]=NULL; |
583 s->scheduled[i]=NULL; | 590 s->scheduled[i]=NULL; |
584 } | 591 } |
585 | 592 |
593 s->s = fd; | |
586 s->server=NULL; | 594 s->server=NULL; |
587 s->server_state=0; | 595 s->server_state=0; |
588 s->server_caps=0; | 596 s->server_caps=0; |
589 | 597 |
590 s->cseq=0; | 598 s->cseq=0; |
603 path++; | 611 path++; |
604 if ((s->param = strchr(s->path, '?')) != NULL) | 612 if ((s->param = strchr(s->path, '?')) != NULL) |
605 s->param++; | 613 s->param++; |
606 //mp_msg(MSGT_OPEN, MSGL_INFO, "path=%s\n", s->path); | 614 //mp_msg(MSGT_OPEN, MSGL_INFO, "path=%s\n", s->path); |
607 //mp_msg(MSGT_OPEN, MSGL_INFO, "param=%s\n", s->param ? s->param : "NULL"); | 615 //mp_msg(MSGT_OPEN, MSGL_INFO, "param=%s\n", s->param ? s->param : "NULL"); |
608 s->s = fd; | |
609 | |
610 if (s->s < 0) { | |
611 mp_msg(MSGT_OPEN, MSGL_ERR, "rtsp: failed to connect to '%s'\n", s->host); | |
612 rtsp_close(s); | |
613 return NULL; | |
614 } | |
615 | 616 |
616 s->server_state=RTSP_CONNECTED; | 617 s->server_state=RTSP_CONNECTED; |
617 | 618 |
618 /* now let's send an options request. */ | 619 /* now let's send an options request. */ |
619 rtsp_schedule_field(s, "CSeq: 1"); | 620 rtsp_schedule_field(s, "CSeq: 1"); |
628 rtsp_request_options(s, NULL); | 629 rtsp_request_options(s, NULL); |
629 | 630 |
630 return s; | 631 return s; |
631 } | 632 } |
632 | 633 |
633 | |
634 /* | |
635 * closes an rtsp connection | |
636 */ | |
637 | |
638 void rtsp_close(rtsp_t *s) { | |
639 | |
640 if (s->server_state) | |
641 { | |
642 if (s->server_state == RTSP_PLAYING) | |
643 rtsp_request_teardown (s, NULL); | |
644 closesocket (s->s); | |
645 } | |
646 | |
647 if (s->path) free(s->path); | |
648 if (s->host) free(s->host); | |
649 if (s->mrl) free(s->mrl); | |
650 if (s->session) free(s->session); | |
651 if (s->user_agent) free(s->user_agent); | |
652 rtsp_free_answers(s); | |
653 rtsp_unschedule_all(s); | |
654 free(s); | |
655 } | |
656 | 634 |
657 /* | 635 /* |
658 * search in answers for tags. returns a pointer to the content | 636 * search in answers for tags. returns a pointer to the content |
659 * after the first matched tag. returns NULL if no match found. | 637 * after the first matched tag. returns NULL if no match found. |
660 */ | 638 */ |