Updated RTMP output to use Util::ResizeablePointer
This commit is contained in:
		
							parent
							
								
									db1ad97c36
								
							
						
					
					
						commit
						05d1fa5c8d
					
				
					 1 changed files with 6 additions and 15 deletions
				
			
		| 
						 | 
					@ -3,6 +3,7 @@
 | 
				
			||||||
#include <mist/defines.h>
 | 
					#include <mist/defines.h>
 | 
				
			||||||
#include <mist/stream.h>
 | 
					#include <mist/stream.h>
 | 
				
			||||||
#include <mist/encode.h>
 | 
					#include <mist/encode.h>
 | 
				
			||||||
 | 
					#include <mist/util.h>
 | 
				
			||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
#include <cstring>
 | 
					#include <cstring>
 | 
				
			||||||
#include <cstdlib>
 | 
					#include <cstdlib>
 | 
				
			||||||
| 
						 | 
					@ -181,8 +182,7 @@ namespace Mist {
 | 
				
			||||||
                         0, 0, 0, 0}; //bytes 12-15 = extended timestamp
 | 
					                         0, 0, 0, 0}; //bytes 12-15 = extended timestamp
 | 
				
			||||||
    char dataheader[] ={0, 0, 0, 0, 0};
 | 
					    char dataheader[] ={0, 0, 0, 0, 0};
 | 
				
			||||||
    unsigned int dheader_len = 1;
 | 
					    unsigned int dheader_len = 1;
 | 
				
			||||||
    static char * swappyPointer = 0;
 | 
					    static Util::ResizeablePointer swappy;
 | 
				
			||||||
    static uint32_t swappySize = 0;
 | 
					 | 
				
			||||||
    char * tmpData = 0;//pointer to raw media data
 | 
					    char * tmpData = 0;//pointer to raw media data
 | 
				
			||||||
    unsigned int data_len = 0;//length of processed media data
 | 
					    unsigned int data_len = 0;//length of processed media data
 | 
				
			||||||
    thisPacket.getString("data", tmpData, data_len);
 | 
					    thisPacket.getString("data", tmpData, data_len);
 | 
				
			||||||
| 
						 | 
					@ -234,21 +234,12 @@ namespace Mist {
 | 
				
			||||||
        dataheader[0] |= 0x10;
 | 
					        dataheader[0] |= 0x10;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      if (track.codec == "PCM"){
 | 
					      if (track.codec == "PCM"){
 | 
				
			||||||
        if (track.size == 16){
 | 
					        if (track.size == 16 && swappy.allocate(data_len)){
 | 
				
			||||||
          if (swappySize < data_len){
 | 
					 | 
				
			||||||
            char * tmp = (char*)realloc(swappyPointer, data_len);
 | 
					 | 
				
			||||||
            if (!tmp){
 | 
					 | 
				
			||||||
              FAIL_MSG("Could not allocate data for PCM endianness swap!");
 | 
					 | 
				
			||||||
              return;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            swappyPointer = tmp;
 | 
					 | 
				
			||||||
            swappySize = data_len;
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          for (uint32_t i = 0; i < data_len; i+=2){
 | 
					          for (uint32_t i = 0; i < data_len; i+=2){
 | 
				
			||||||
            swappyPointer[i] = tmpData[i+1];
 | 
					            swappy[i] = tmpData[i+1];
 | 
				
			||||||
            swappyPointer[i+1] = tmpData[i];
 | 
					            swappy[i+1] = tmpData[i];
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          tmpData = swappyPointer;
 | 
					          tmpData = swappy;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        dataheader[0] |= 0x30;
 | 
					        dataheader[0] |= 0x30;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue