[pulseaudio-commits] r2339 - in /branches/coling/raop_play/pulsified: Makefile Makefile.in aes.c aes.h base64.c base64.h raop_client.c rtsp_client.c rtsp_client.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu May 1 17:36:38 PDT 2008


Author: coling
Date: Fri May  2 02:36:36 2008
New Revision: 2339

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2339&root=pulseaudio&view=rev
Log:
Changes for the pulsified version

Removed:
    branches/coling/raop_play/pulsified/aes.c
    branches/coling/raop_play/pulsified/aes.h
    branches/coling/raop_play/pulsified/base64.c
    branches/coling/raop_play/pulsified/base64.h
    branches/coling/raop_play/pulsified/rtsp_client.c
    branches/coling/raop_play/pulsified/rtsp_client.h
Modified:
    branches/coling/raop_play/pulsified/Makefile
    branches/coling/raop_play/pulsified/Makefile.in
    branches/coling/raop_play/pulsified/raop_client.c

Modified: branches/coling/raop_play/pulsified/Makefile
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/raop_play/pulsified/Makefile?rev=2339&root=pulseaudio&r1=2338&r2=2339&view=diff
==============================================================================
--- branches/coling/raop_play/pulsified/Makefile (original)
+++ branches/coling/raop_play/pulsified/Makefile Fri May  2 02:36:36 2008
@@ -12,15 +12,17 @@
 TARGET=raop_play
 DESTDIR =
 
-CFLAGS=-Wall
-OBJS := raop_play.o raop_client.o rtsp_client.o aexcl_lib.o base64.o aes.o m4a_stream.o \
+PULSEDIR = ..
+CFLAGS=-Wall -I$(PULSEDIR)/src
+OBJS := raop_play.o raop_client.o aexcl_lib.o m4a_stream.o \
 audio_stream.o wav_stream.o mp3_stream.o flac_stream.o ogg_stream.o aac_stream.o pls_stream.o \
 pcm_stream.o flac_stream.o
+LIBS=$(PULSEDIR)/src/.libs/libpulse.a $(PULSEDIR)/src/.libs/libpulsecore.a $(PULSEDIR)/src/.libs/librtp.a $(PULSEDIR)/src/.libs/libsocket-util.a
 
 all: $(TARGET)
 
-raop_play: $(OBJS)
-	$(CC) -o $@  -lssl -lsamplerate -lid3tag $^
+raop_play: $(OBJS) $(LIBS)
+	$(CC) -o $@  -lssl -lsamplerate -lid3tag -lpthread $^ $(LIBS)
 
 install:
 	$(mkinstalldirs) $(DESTDIR)$(bindir)/
@@ -37,11 +39,10 @@
 %.o : %.c
 	$(CC) $(CFLAGS) -c $< -o $@
 
-COMMONE_HEADERS := aexcl_lib.h raop_play.h raop_client.h rtsp_client.h m4a_stream.h \
+COMMONE_HEADERS := aexcl_lib.h raop_play.h raop_client.h m4a_stream.h \
 pls_stream.h
 
 aexcl_lib.o: $(COMMONE_HEADERS)
 raop_play.o: $(COMMONE_HEADERS)
 raop_client.o: $(COMMONE_HEADERS)
-rtsp_client.o: $(COMMONE_HEADERS)
 m4a_stream.o: $(COMMONE_HEADERS)

Modified: branches/coling/raop_play/pulsified/Makefile.in
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/coling/raop_play/pulsified/Makefile.in?rev=2339&root=pulseaudio&r1=2338&r2=2339&view=diff
==============================================================================
--- branches/coling/raop_play/pulsified/Makefile.in (original)
+++ branches/coling/raop_play/pulsified/Makefile.in Fri May  2 02:36:36 2008
@@ -12,15 +12,17 @@
 TARGET=raop_play
 DESTDIR =
 
-CFLAGS=-Wall
-OBJS := raop_play.o raop_client.o rtsp_client.o aexcl_lib.o base64.o aes.o m4a_stream.o \
+PULSEDIR = ..
+CFLAGS=-Wall -I$(PULSEDIR)/src
+OBJS := raop_play.o raop_client.o aexcl_lib.o m4a_stream.o \
 audio_stream.o wav_stream.o mp3_stream.o flac_stream.o ogg_stream.o aac_stream.o pls_stream.o \
 pcm_stream.o flac_stream.o
+LIBS=$(PULSEDIR)/src/.libs/libpulse.a $(PULSEDIR)/src/.libs/libpulsecore.a $(PULSEDIR)/src/.libs/librtp.a $(PULSEDIR)/src/.libs/libsocket-util.a
 
 all: $(TARGET)
 
-raop_play: $(OBJS)
-	$(CC) -o $@  -lssl -lsamplerate -lid3tag $^
+raop_play: $(OBJS) $(LIBS)
+	$(CC) -o $@  -lssl -lsamplerate -lid3tag -lpthread $^ $(LIBS)
 
 install:
 	$(mkinstalldirs) $(DESTDIR)$(bindir)/
@@ -37,11 +39,10 @@
 %.o : %.c
 	$(CC) $(CFLAGS) -c $< -o $@
 
-COMMONE_HEADERS := aexcl_lib.h raop_play.h raop_client.h rtsp_client.h m4a_stream.h \
+COMMONE_HEADERS := aexcl_lib.h raop_play.h raop_client.h m4a_stream.h \
 pls_stream.h
 
 aexcl_lib.o: $(COMMONE_HEADERS)
 raop_play.o: $(COMMONE_HEADERS)
 raop_client.o: $(COMMONE_HEADERS)
-rtsp_client.o: $(COMMONE_HEADERS)
 m4a_stream.o: $(COMMONE_HEADERS)

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=2339&root=pulseaudio&r1=2338&r2=2339&view=diff
==============================================================================
--- branches/coling/raop_play/pulsified/raop_client.c (original)
+++ branches/coling/raop_play/pulsified/raop_client.c Fri May  2 02:36:36 2008
@@ -22,16 +22,19 @@
 #include <openssl/err.h>
 #include <openssl/rand.h>
 #include <openssl/rsa.h>
+#include <openssl/aes.h>
 #include <openssl/engine.h>
 
 #include <asm/types.h>
 #include "aexcl_lib.h"
-#include "rtsp_client.h"
 #include "raop_client.h"
-#include "base64.h"
-#include "aes.h"
 #include "raop_play.h"
 #include "audio_stream.h"
+
+#include "../config.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
@@ -44,7 +47,8 @@
 #define VOLUME_MAX 0
 
 typedef struct raopcl_data_t {
-  rtspcl_t *rtspcl;
+  pa_rtsp_context *rtsp;
+        //rtspcl_t *rtspcl;
   __u8 iv[16]; // initialization vector for aes-cbc
   __u8 nv[16]; // next vector for aes-cbc
   __u8 key[16]; // key for aes-cbc
@@ -58,7 +62,7 @@
   int wblk_remsize;
   pause_state_t pause;
   int wait_songdone;
-  aes_context ctx;
+  AES_KEY ctx;
   __u8 *data;
   __u8 min_sdata[MINIMUM_SAMPLE_SIZE*4+16];
   int min_sdata_size;
@@ -84,9 +88,9 @@
         char e[] = "AQAB";
 
   rsa=RSA_new();
-  size=base64_decode(n,modules);
+  size=pa_base64_decode(n,modules);
   rsa->n=BN_bin2bn(modules,size,NULL);
-  size=base64_decode(e,exponent);
+  size=pa_base64_decode(e,exponent);
   rsa->e=BN_bin2bn(exponent,size,NULL);
   size=RSA_public_encrypt(len, text, res, rsa, RSA_PKCS1_OAEP_PADDING);
   RSA_free(rsa);
@@ -102,21 +106,9 @@
   while(i+16<=size){
     buf=data+i;
     for(j=0;j<16;j++) buf[j] ^= raopcld->nv[j];
-    aes_encrypt(&raopcld->ctx, buf, buf);
+    AES_encrypt(buf, buf, &raopcld->ctx);
     memcpy(raopcld->nv,buf,16);
     i+=16;
-  }
-  if(i<size){
-#if 0
-    INFMSG("%s: a block less than 16 bytes(%d) is not encrypted\n",__func__, size-i);
-    memset(tmp,0,16);
-    memcpy(tmp,data+i,size-i);
-    for(j=0;j<16;j++) tmp[j] ^= raopcld->nv[j];
-    aes_encrypt(&raopcld->ctx, tmp, tmp);
-    memcpy(raopcld->nv,tmp,16);
-    memcpy(data+i,tmp,16);
-    i+=16;
-#endif
   }
   return i;
 }
@@ -187,7 +179,7 @@
 
   if((raopcld->sfd=open_tcp_socket(NULL, &myport))==-1) return -1;
   if(get_tcp_connect_by_host(raopcld->sfd, raopcld->addr,
-           rtspcl_get_server_port(raopcld->rtspcl))) {
+           raopcld->rtsp->port)) {
     close(raopcld->sfd);
     raopcld->sfd=-1;
     return -1;
@@ -212,7 +204,7 @@
     return 0;
   case OP_PAUSE:
     if(time(NULL)-raopcld->paused_time<3) return 0;
-    rtspcl_flush(raopcld->rtspcl);
+    pa_rtsp_flush(raopcld->rtsp);
     raopcld->paused_time=time(NULL);
     return 1;
   case NODATA_PAUSE:
@@ -287,7 +279,7 @@
   }
   memcpy(raopcld->nv,raopcld->iv,sizeof(raopcld->nv));
   raopcld->volume=VOLUME_DEF;
-        aes_set_key(&raopcld->ctx, raopcld->key, 128);
+        AES_set_encrypt_key(raopcld->key, 128, &raopcld->ctx);
   // prepare a small silent data to send during pause period.
   ds.u.mem.size=MINIMUM_SAMPLE_SIZE*4;
   ds.u.mem.data=sdata;
@@ -303,8 +295,8 @@
   if(!p) return -1;
 
   raopcld=(raopcl_data_t *)p;
-  if(raopcld->rtspcl)
-    rtspcl_close(raopcld->rtspcl);
+  if(raopcld->rtsp)
+    pa_rtsp_disconnect(raopcld->rtsp);
   if(raopcld->data) free(raopcld->data);
   if(raopcld->addr) free(raopcld->addr);
   free(raopcld);
@@ -319,7 +311,7 @@
   char *sac=NULL,*key=NULL,*iv=NULL;
   char sdp[1024];
   int rval=-1;
-  key_data_t *setup_kd=NULL;
+        pa_headerlist *setup_kd=NULL;
   char *aj, *token, *pc;
   const char delimiters[] = ";";
   __u8 rsakey[512];
@@ -331,16 +323,16 @@
   RAND_bytes(buf, sizeof(buf));
   sprintf(sid, "%d", *((__u32*)buf));
   sprintf(sci, "%08x%08x",*((__u32*)(buf+4)),*((__u32*)(buf+8)));
-  base64_encode(buf+12,16,&sac);
-  if(!(raopcld->rtspcl=rtspcl_open())) goto erexit;
-  if(rtspcl_set_useragent(raopcld->rtspcl,"iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)")) goto erexit;
-  if(rtspcl_add_exthds(raopcld->rtspcl,"Client-Instance", sci)) goto erexit;
-  if(rtspcl_connect(raopcld->rtspcl, host, destport, sid)) goto erexit;
+  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;
 
   i=rsa_encrypt(raopcld->key,16,rsakey);
-  base64_encode(rsakey,i,&key);
+  pa_base64_encode(rsakey,i,&key);
   remove_char_from_string(key,'=');
-  base64_encode(raopcld->iv,16,&iv);
+  pa_base64_encode(raopcld->iv,16,&iv);
   remove_char_from_string(iv,'=');
   sprintf(sdp,
             "v=0\r\n"
@@ -353,13 +345,13 @@
             "a=fmtp:96 4096 0 16 40 10 14 2 255 0 0 44100\r\n"
             "a=rsaaeskey:%s\r\n"
             "a=aesiv:%s\r\n",
-            sid, rtspcl_local_ip(raopcld->rtspcl), host, key, iv);
+            sid, pa_rtsp_localip(raopcld->rtsp), host, key, iv);
   remove_char_from_string(sac,'=');
-  if(rtspcl_add_exthds(raopcld->rtspcl, "Apple-Challenge", sac)) goto erexit;
-  if(rtspcl_annouce_sdp(raopcld->rtspcl, sdp)) goto erexit;
-  if(rtspcl_mark_del_exthds(raopcld->rtspcl, "Apple-Challenge")) goto erexit;
-  if(rtspcl_setup(raopcld->rtspcl, &setup_kd)) goto erexit;
-  if(!(aj=kd_lookup(setup_kd,"Audio-Jack-Status"))) {
+  if(pa_headerlist_puts(raopcld->rtsp->headers, "Apple-Challenge", sac)) goto erexit;
+  if(!pa_rtsp_announce(raopcld->rtsp, sdp)) goto erexit;
+  if(pa_headerlist_remove(raopcld->rtsp->headers, "Apple-Challenge")) goto erexit;
+  if(!pa_rtsp_setup(raopcld->rtsp, &setup_kd)) goto erexit;
+  if(!(aj=pa_xstrdup(pa_headerlist_gets(setup_kd,"Audio-Jack-Status")))) {
     ERRMSG("%s: Audio-Jack-Status is missing\n",__func__);
     goto erexit;
   }
@@ -379,7 +371,7 @@
     token=strtok(NULL,delimiters);
   }
 
-  if(rtspcl_record(raopcld->rtspcl)) goto erexit;
+  if(!pa_rtsp_record(raopcld->rtsp)) goto erexit;
 
   // keep host address and port information
   if(realloc_memory((void**)&raopcld->addr,strlen(host)+1,__func__)) goto erexit;
@@ -393,7 +385,8 @@
   if(sac) free(sac);
   if(key) free(key);
   if(iv) free(iv);
-  free_kd(setup_kd);
+        if (setup_kd)
+    pa_headerlist_free(setup_kd);
   return rval;
 
 
@@ -410,17 +403,19 @@
   raopcl_data_t *raopcld=(raopcl_data_t *)p;
   if(!p) return -1;
 
-  if(!raopcld->rtspcl) return -1;
+  if(!raopcld->rtsp) return -1;
   raopcld->volume=VOLUME_MIN+(VOLUME_MAX-VOLUME_MIN)*vol/100;
   sprintf(a, "volume: %d.000000\r\n", raopcld->volume);
-  return rtspcl_set_parameter(raopcld->rtspcl,a);
+  if (pa_rtsp_setparameter(raopcld->rtsp,a)) return 0;
+        return -1;
 }
 
 int raopcl_flush_stream(raopcl_t *p)
 {
   raopcl_data_t *raopcld=(raopcl_data_t *)p;
   if(!p) return -1;
-  return rtspcl_flush(raopcld->rtspcl);
+        if (pa_rtsp_flush(raopcld->rtsp)) return 0;
+  return -1;
 }
 
 int raopcl_set_pause(raopcl_t *p, pause_state_t pause)
@@ -431,7 +426,7 @@
   raopcld->pause=pause;
   switch(pause){
   case OP_PAUSE:
-    rtspcl_flush(raopcld->rtspcl);
+    pa_rtsp_flush(raopcld->rtsp);
   case NODATA_PAUSE:
     set_fd_event(raopcld->sfd, RAOP_FD_READ, fd_event_callback,(void*)raopcld);
     raopcld->paused_time=time(NULL);




More information about the pulseaudio-commits mailing list