Changeset 90:a4dbc92ef913 in roaraudio


Ignore:
Timestamp:
07/13/08 01:02:28 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added a lot of basic meta stuff

Location:
roard
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • roard/include/meta.h

    r89 r90  
    66#include <roaraudio.h> 
    77 
     8int stream_meta_set   (int id, int type, char * name, char * val); 
     9int stream_meta_add   (int id, int type, char * name, char * val); 
     10int stream_meta_get   (int id, int type, char * name, char * val, size_t len); 
     11int stream_meta_clear (int id); 
     12 
    813#endif 
    914 
  • roard/meta.c

    r88 r90  
    33#include "roard.h" 
    44 
     5int stream_meta_set   (int id, int type, char * name, char * val) { 
     6 int i; 
     7 struct roar_stream_server * s = g_streams[id]; 
     8 
     9 if ( s == NULL ) 
     10  return -1; 
     11 
     12 for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) 
     13  if ( s->meta[i].type == type ) { 
     14   s->meta[i].type = ROAR_META_TYPE_NONE; 
     15   if ( s->meta[i].value ) 
     16    free(s->meta[i].value); 
     17   s->meta[i].value = NULL; 
     18  } 
     19 
     20 return stream_meta_add(id, type, name, val); 
     21} 
     22 
     23int stream_meta_add   (int id, int type, char * name, char * val) { 
     24 int i; 
     25 char * c; 
     26 struct roar_stream_server * s = g_streams[id]; 
     27 
     28 if ( s == NULL ) 
     29  return -1; 
     30 
     31 for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) { 
     32  if ( s->meta[i].type == ROAR_META_TYPE_NONE ) { 
     33   s->meta[i].type = type; 
     34 
     35   if ( name == NULL ) { 
     36    s->meta[i].key[0] = 0; 
     37   } else { 
     38    strncpy(s->meta[i].key, name, ROAR_META_MAX_NAMELEN); 
     39   } 
     40 
     41   if ( (c = malloc(strlen(val))) == NULL ) { 
     42    s->meta[i].type = ROAR_META_TYPE_NONE; 
     43    s->meta[i].key[0] = 0; 
     44    return -1; 
     45   } 
     46 
     47   strcpy(c, val); 
     48   s->meta[i].value = c; 
     49 
     50   return 0; 
     51  } 
     52 } 
     53 
     54 return -1; 
     55} 
     56 
     57int stream_meta_get   (int id, int type, char * name, char * val, size_t len) { 
     58 int i; 
     59 struct roar_stream_server * s = g_streams[id]; 
     60 
     61 if ( s == NULL ) 
     62  return -1; 
     63 
     64 for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) { 
     65  if ( s->meta[i].type == type ) { 
     66   if ( name != NULL ) 
     67    if ( strncmp(s->meta[i].key, name, ROAR_META_MAX_NAMELEN) != 0 ) 
     68     continue; 
     69 
     70   if ( strlen(s->meta[i].value) > (len - 1) ) 
     71    return -1; 
     72 
     73   strcpy(val, s->meta[i].value); 
     74 
     75   return 0; 
     76  } 
     77 } 
     78 
     79 return -1; 
     80} 
     81 
     82int stream_meta_clear (int id) { 
     83 int i; 
     84 struct roar_stream_server * s = g_streams[id]; 
     85 
     86 if ( s == NULL ) 
     87  return -1; 
     88 
     89 for (i = 0; i < ROAR_META_MAX_PER_STREAM; i++) { 
     90  s->meta[i].type   = ROAR_META_TYPE_NONE; 
     91  if ( s->meta[i].value ) 
     92   free(s->meta[i].value); 
     93  s->meta[i].value  = NULL; 
     94  s->meta[i].key[0] = 0; 
     95 } 
     96 
     97 return 0; 
     98} 
     99 
    5100//ll 
  • roard/streams.c

    r87 r90  
    5353   for (j = 0; j < ROAR_MAX_CHANNELS; j++) 
    5454    ((struct roar_stream_server*)n)->mixer.mixer[j] = 65535; 
    55    for (j = 0; j < ROAR_META_MAX_PER_STREAM; j++) 
    56     ((struct roar_stream_server*)n)->meta[j].type = ROAR_META_TYPE_NONE; 
     55   for (j = 0; j < ROAR_META_MAX_PER_STREAM; j++) { 
     56    ((struct roar_stream_server*)n)->meta[j].type   = ROAR_META_TYPE_NONE; 
     57    ((struct roar_stream_server*)n)->meta[j].key[0] = 0; 
     58    ((struct roar_stream_server*)n)->meta[j].value  = NULL; 
     59   } 
    5760 
    5861   g_streams[i] = (struct roar_stream_server*)n; 
Note: See TracChangeset for help on using the changeset viewer.