Changeset 181

Show
Ignore:
Timestamp:
11/05/07 12:36:25 (10 months ago)
Author:
sip
Message:

Fixed bug on frame creation.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • app_h324m/app_h324m.c

    r180 r181  
    136136        unsigned int len = 0; 
    137137        struct ast_frame* send; 
     138        unsigned char* data = 0; 
    138139 
    139140        /* Get data & size */ 
     
    163164 
    164165                        /* Check correct mode and length */ 
    165                         if (bs==-1 || framelength<bs) 
     166                        if (bs==-1 || framelength<(unsigned)bs) 
    166167                                /* Exit */ 
    167168                                return NULL; 
     
    172173                        send->data = (void*)send + AST_FRIENDLY_OFFSET; 
    173174                        send->datalen = framelength + 1; /* +1 because the the octet with the CMR */ 
     175                        data = send->data; 
    174176                        /* Set header cmr */ 
    175                         ((unsigned char*)(send->data))[0] = 0xF0; 
     177                        data[0] = 0xF0; 
     178                        /* Increase pointer to match frame */ 
     179                        data++; 
    176180                        /* Copy */ 
    177                         memcpy(send->data+1, framedata, framelength); 
     181                        memcpy(data, framedata, framelength); 
    178182                         
    179183                        /*Convert IF2 into AMR MIME format*/ 
    180184 
    181185                        /*Reverse bytes*/ 
    182                         TIFFReverseBits(send->data+1, framelength); 
     186                        TIFFReverseBits(data, framelength); 
    183187 
    184188                        /*If amr has a byte more than if2 */ 
     
    186190                        { 
    187191                                /* Set last byte */ 
    188                                 ((unsigned char *)(send->data+1))[bs] = ((unsigned char *)(send->data+1))[bs - 1] << 4; 
     192                                data[bs] = data[bs - 1] << 4; 
    189193                                /*Increase size of frame*/ 
    190194                                send->datalen++; 
     
    193197                        /* For each byte */ 
    194198                        for(j=bs-1; j>0; j--) 
    195                                 ((unsigned char *)(send->data+1))[j] = ((unsigned char *)(send->data+1))[j] >> 4 | ((unsigned char *)(send->data+1))[j-1] << 4; 
     199                                data[j] = data[j] >> 4 | data[j-1] << 4; 
    196200 
    197201                        /* Calculate first byte */ 
    198                         ((unsigned char *)(send->data+1))[0] = mode << 3 | 0x04; 
    199  
     202                        data[0] = mode << 3 | 0x04; 
    200203 
    201204                        /* Set video type */ 
     
    254257                        /* Create frame */ 
    255258                        send = (struct ast_frame *) malloc(sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET + 2 + len); 
     259 
     260                        /* Set data*/ 
     261                        send->data = (unsigned char*)send + AST_FRIENDLY_OFFSET; 
     262                        data = send->data; 
    256263                                 
    257264                        /* if its first pcaket of a frame */ 
    258265                        if (vt->first) 
    259266                        { 
    260                                 /* Set data*/ 
    261                                 send->data = (unsigned char*)send + AST_FRIENDLY_OFFSET; 
    262267                                /* If it's not empty */ 
    263268                                if (vt->bufferLength) 
     
    266271                                        send->datalen = vt->bufferLength; 
    267272                                        /* Copy */ 
    268                                         memcpy(send->data+2, vt->buffer+2, vt->bufferLength-2); 
     273                                        memcpy(data+2, vt->buffer+2, vt->bufferLength-2); 
    269274                                } else { 
    270275                                        /* Only header part by bow */ 
     
    272277                                } 
    273278                                /* Set header */ 
    274                                 ((unsigned char*)(send->data))[0] = 0x04; 
    275                                 ((unsigned char*)(send->data))[1] = 0x00;  
     279                                data[0] = 0x04; 
     280                                data[1] = 0x00;  
    276281                        } else { 
    277                                 /* Set data*/ 
    278                                 send->data = (unsigned char*)send + AST_FRIENDLY_OFFSET; 
     282                                /* Set data len */ 
    279283                                send->datalen =  vt->bufferLength + 2  ; 
    280284                                /* If it's not empty */ 
    281285                                if (vt->bufferLength) 
    282286                                        /* Copy */ 
    283                                         memcpy(send->data+2, vt->buffer, vt->bufferLength); 
     287                                        memcpy(data+2, vt->buffer, vt->bufferLength); 
    284288                                /* Set header */ 
    285                                 ((unsigned char*)(send->data))[0] = 0x00; 
    286                                 ((unsigned char*)(send->data))[1] = 0x00; 
     289                                data[0] = 0x00; 
     290                                data[1] = 0x00; 
    287291                        } 
    288292                         
     
    297301                        } else if (i>0 && found) { 
    298302                                /* Copy the begining to the packet to send*/ 
    299                                 memcpy(send->data+send->datalen,framedata,i); 
     303                                memcpy(data+send->datalen,framedata,i); 
    300304                                /* Increase size */ 
    301305                                send->datalen += i; 
Copyright 2006 - Sergio García Murillo
Powered by Trac - Edgewall Software