Changeset 121:1ed1307ca42e in roaraudio


Ignore:
Timestamp:
07/13/08 15:15:42 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

now using a extra function to update meta data and open the stream so we support chained Ogg :)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarvorbis.c

    r120 r121  
    2727} 
    2828 
    29 int main (int argc, char * argv[]) { 
     29int update_stream (struct roar_connection * con, struct roar_stream * s, int * out, OggVorbis_File * vf, char * file) { 
     30 vorbis_info *vi = ov_info(vf, -1); 
    3031 int    bits     = 16; 
    3132 int    codec    = ROAR_CODEC_DEFAULT; 
     33 char **ptr = ov_comment(vf, -1)->user_comments; 
     34 char key[80], value[80]; 
     35 int j, h = 0; 
     36 struct roar_meta   meta; 
     37 
     38 fprintf(stderr, "\n"); 
     39 
     40 if ( *out != -1 ) 
     41  close(*out); 
     42 
     43 fprintf(stderr, "Audio: %i channel, %liHz\n\n", vi->channels, vi->rate); 
     44 
     45 if ( (*out = roar_simple_new_stream_obj(con, s, vi->rate, vi->channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
     46  roar_disconnect(con); 
     47  return -1; 
     48 } 
     49 
     50 
     51 meta.value = value; 
     52 meta.key[0] = 0; 
     53 
     54 roar_stream_meta_set(con, s, ROAR_META_MODE_CLEAR, &meta); 
     55 
     56 meta.type = ROAR_META_TYPE_FILENAME; 
     57 strncpy(value, file, 79); 
     58 roar_stream_meta_set(con, s, ROAR_META_MODE_SET, &meta); 
     59 
     60 while(*ptr){ 
     61   for (j = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) 
     62    key[j] = (*ptr)[j]; 
     63    key[j] = 0; 
     64 
     65   for (j++, h = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) 
     66    value[h++] = (*ptr)[j]; 
     67    value[h]   = 0; 
     68 
     69   meta.type = roar_meta_inttype(key); 
     70   if ( meta.type != -1 ) 
     71    roar_stream_meta_set(con, s, ROAR_META_MODE_SET, &meta); 
     72 
     73   fprintf(stderr, "Meta %-16s: %s\n", key, value); 
     74   ++ptr; 
     75 } 
     76 
     77 return 0; 
     78} 
     79 
     80int main (int argc, char * argv[]) { 
    3281 char * server   = NULL; 
    3382 char * file     = NULL; 
     
    82131 } 
    83132 
    84  { 
    85   vorbis_info *vi = ov_info(&vf, -1); 
    86  
    87   fprintf(stderr, "Audio: %i channel, %liHz\n\n", vi->channels, vi->rate); 
    88  
    89   if ( (out = roar_simple_new_stream_obj(&con, &s, vi->rate, vi->channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
    90    roar_disconnect(&con); 
    91    return -1; 
    92   } 
    93  } 
    94  
    95  { 
    96   char **ptr = ov_comment(&vf, -1)->user_comments; 
    97   char key[80], value[80]; 
    98   int j, h = 0; 
    99   struct roar_meta   meta; 
    100  
    101   meta.value = value; 
    102   meta.key[0] = 0; 
    103  
    104   roar_stream_meta_set(&con, &s, ROAR_META_MODE_CLEAR, &meta); 
    105  
    106   meta.type = ROAR_META_TYPE_FILENAME; 
    107   strncpy(value, file, 79); 
    108   roar_stream_meta_set(&con, &s, ROAR_META_MODE_SET, &meta); 
    109  
    110  
    111  
    112   while(*ptr){ 
    113     for (j = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) 
    114      key[j] = (*ptr)[j]; 
    115      key[j] = 0; 
    116  
    117     for (j++, h = 0; (*ptr)[j] != 0 && (*ptr)[j] != '='; j++) 
    118      value[h++] = (*ptr)[j]; 
    119      value[h]   = 0; 
    120  
    121     meta.type = roar_meta_inttype(key); 
    122     if ( meta.type != -1 ) 
    123      roar_stream_meta_set(&con, &s, ROAR_META_MODE_SET, &meta); 
    124  
    125     fprintf(stderr, "Meta %-16s: %s\n", key, value); 
    126     ++ptr; 
    127   } 
    128  
    129  } 
     133// if ( update_stream(&con, &s, &out, &vf, file) == -1 ) 
     134//  return -1; 
    130135 
    131136 while (!eof) { 
    132137  long ret = ov_read(&vf, pcmout, sizeof(pcmout), 0, 2, 1, &current_section); 
     138 
     139  if ( last_section != current_section ) 
     140   if ( update_stream(&con, &s, &out, &vf, file) == -1 ) 
     141    return -1; 
    133142 
    134143  last_section = current_section; 
Note: See TracChangeset for help on using the changeset viewer.