[pulseaudio-commits] r2361 - in /branches/coling/raop_play/pulsified: raop_client.c raop_client.h raop_play.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat May 3 17:44:42 PDT 2008
Author: coling
Date: Sun May 4 02:44:41 2008
New Revision: 2361
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2361&root=pulseaudio&view=rev
Log:
Update to run a pa_mainloop (in a fairly hacky way) to test the pa_socket_client based rtsp stuff.
This also calculates the url in the more appropriate way.
Modified:
branches/coling/raop_play/pulsified/raop_client.c
branches/coling/raop_play/pulsified/raop_client.h
branches/coling/raop_play/pulsified/raop_play.c
Modified: branches/coling/raop_play/pulsified/raop_client.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/raop_play/pulsified/raop_client.c?rev=2361&root=pulseaudio&r1=2360&r2=2361&view=diff
==============================================================================
--- branches/coling/raop_play/pulsified/raop_client.c (original)
+++ branches/coling/raop_play/pulsified/raop_client.c Sun May 4 02:44:41 2008
@@ -31,10 +31,10 @@
#include "raop_play.h"
#include "audio_stream.h"
-#include "../config.h"
+#include "pulsecore/core-util.h"
+#include "pulse/xmalloc.h"
#include "modules/rtp/base64.h"
#include "modules/rtp/rtsp.h"
-#include "pulse/xmalloc.h"
#define JACK_STATUS_DISCONNECTED 0
#define JACK_STATUS_CONNECTED 1
@@ -303,10 +303,11 @@
return 0;
}
-int raopcl_connect(raopcl_t *p, char *host,__u16 destport)
+int raopcl_connect(pa_mainloop* mainloop, pa_mainloop_api* mainloop_api, raopcl_t *p, char *host,__u16 destport)
{
__u8 buf[4+8+16];
char sid[16];
+ char *url;
char sci[24];
char *sac=NULL,*key=NULL,*iv=NULL;
char sdp[1024];
@@ -317,17 +318,26 @@
__u8 rsakey[512];
int i;
raopcl_data_t *raopcld;
+ int ret;
if(!p) return -1;
raopcld=(raopcl_data_t *)p;
RAND_bytes(buf, sizeof(buf));
- sprintf(sid, "%d", *((__u32*)buf));
+ snprintf(sid, 15, "%u", *((__u32*)buf));
sprintf(sci, "%08x%08x",*((__u32*)(buf+4)),*((__u32*)(buf+8)));
pa_base64_encode(buf+12,16,&sac);
if(!(raopcld->rtsp=pa_rtsp_context_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)"))) goto erexit;
//if(rtspcl_set_useragent(raopcld->rtspcl,"iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)")) goto erexit;
- if(pa_headerlist_puts(raopcld->rtsp->headers, "Client-Instance", sci)) goto erexit;
- if(!pa_rtsp_connect(raopcld->rtsp, host, destport, sid)) goto erexit;
+ if(pa_headerlist_puts(raopcld->rtsp->headers, "Client-Instance", sci)) goto erexit;
+ if(!pa_rtsp_connect(raopcld->rtsp, mainloop_api, host, destport)) goto erexit;
+ /* We call the mainloop in blocking mode here to allow the connection to be established.
+ Yes, this is totally hacky and requires an internal knowledge of how the aobve pa_rtsp_connect
+ works, but this is only a hacked up test so I'll let it slide just this once ;) */
+ if(pa_mainloop_iterate(mainloop, 1, &ret) < 0) goto erexit;
+
+ url = pa_sprintf_malloc("rtsp://%s/%s", pa_rtsp_localip(raopcld->rtsp), sid);
+ pa_rtsp_set_url(raopcld->rtsp, url);
+ pa_xfree(url);
i=rsa_encrypt(raopcld->key,16,rsakey);
pa_base64_encode(rsakey,i,&key);
Modified: branches/coling/raop_play/pulsified/raop_client.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/raop_play/pulsified/raop_client.h?rev=2361&root=pulseaudio&r1=2360&r2=2361&view=diff
==============================================================================
--- branches/coling/raop_play/pulsified/raop_client.h (original)
+++ branches/coling/raop_play/pulsified/raop_client.h Sun May 4 02:44:41 2008
@@ -20,6 +20,9 @@
#ifndef __RAOP_CLIENT_H_
#define __RAOP_CLIENT_H
+#include "../../airtunes/config.h"
+#include "pulse/mainloop.h"
+
typedef struct raopcl_t {__u32 dummy;} raopcl_t;
typedef enum pause_state_t{
@@ -30,7 +33,7 @@
raopcl_t *raopcl_open();
int raopcl_close(raopcl_t *p);
-int raopcl_connect(raopcl_t *p, char *host,__u16 destport);
+int raopcl_connect(pa_mainloop* mainloop, pa_mainloop_api* mainloop_api, raopcl_t *p, char *host,__u16 destport);
int raopcl_disconnect(raopcl_t *p);
int raopcl_send_sample(raopcl_t *p, __u8 *sample, int count );
int raopcl_update_volume(raopcl_t *p, int vol);
Modified: branches/coling/raop_play/pulsified/raop_play.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/raop_play/pulsified/raop_play.c?rev=2361&root=pulseaudio&r1=2360&r2=2361&view=diff
==============================================================================
--- branches/coling/raop_play/pulsified/raop_play.c (original)
+++ branches/coling/raop_play/pulsified/raop_play.c Sun May 4 02:44:41 2008
@@ -25,6 +25,11 @@
#include "audio_stream.h"
#include "raop_play.h"
+#include "../../airtunes/config.h"
+#include <pulsecore/macro.h>
+#include <pulsecore/thread.h>
+#include <pulse/mainloop.h>
+#include <pulse/mainloop-signal.h>
#define SERVER_PORT 5000
#define MAX_NUM_OF_FDS 4
@@ -41,6 +46,8 @@
dfev_t fds[MAX_NUM_OF_FDS];
}raopld_t;
static raopld_t *raopld;
+
+static pa_mainloop_api *mainloop_api = NULL;
static int print_usage(char *argv[])
@@ -193,6 +200,9 @@
int iact=0;
struct sigaction act;
+ pa_mainloop* mainloop;
+ int ret = 1;
+
/* Assign sig_term as our SIGTERM handler */
act.sa_sigaction = sig_action;
sigemptyset(&act.sa_mask); // no other signals are blocked
@@ -227,9 +237,20 @@
memset(raopld,0,sizeof(raopld_t));
for(i=0;i<MAX_NUM_OF_FDS;i++) raopld->fds[i].fd=-1;
+ if (!(mainloop = pa_mainloop_new())) {
+ fprintf(stderr, "pa_mainloop_new() failed.\n");
+ goto erexit;
+ }
+
+ pa_assert_se(mainloop_api = pa_mainloop_get_api(mainloop));
+ pa_assert_se(pa_signal_init(mainloop_api) == 0);
+#ifdef SIGPIPE
+ signal(SIGPIPE, SIG_IGN);
+#endif
+
raopld->raopcl=raopcl_open();
if(!raopld->raopcl) goto erexit;
- if(raopcl_connect(raopld->raopcl,host,port)) goto erexit;
+ if(raopcl_connect(mainloop, mainloop_api, raopld->raopcl,host,port)) goto erexit;
if(raopcl_update_volume(raopld->raopcl,volume)) goto erexit;
printf("%s\n",RAOP_CONNECTED);
fflush(stdout);
@@ -237,6 +258,7 @@
set_fd_event(0,RAOP_FD_READ,console_read,NULL);
rval=0;
while(!rval){
+ if(pa_mainloop_iterate(mainloop, 0, &ret) < 0) goto erexit;
if(!raopld->auds){
// if audio data is not opened, just check events
rval=main_event_handler(raopld);
@@ -276,6 +298,10 @@
}
rval=raopcl_close(raopld->raopcl);
erexit:
+ if (mainloop) {
+ pa_signal_done();
+ pa_mainloop_free(mainloop);
+ }
if(raopld->auds) auds_close(raopld->auds);
if(raopld) free(raopld);
return rval;
More information about the pulseaudio-commits
mailing list