1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

rewrite ff_data_to_hex

This commit is contained in:
Harlan 2018-08-12 14:10:18 +08:00
parent e9cb8210fc
commit ac6b37de4b
3 changed files with 13 additions and 20 deletions

View file

@ -771,7 +771,7 @@ srs_error_t SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
{
string filename = req->stream+"-"+srs_int2str(segment->sequence_no)+".key";
char hexiv[33];
ff_data_to_hex(hexiv,segment->iv,16,0);
srs_data_to_hex(hexiv,segment->iv,16);
hexiv[32] = '\0';
string key_path;
//if key_url is not set,only use the file name

View file

@ -1051,25 +1051,18 @@ int srs_do_create_dir_recursively(string dir)
return c;
}
char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase)
char *srs_data_to_hex(char *des,const u_int8_t *src,int len)
{
int i;
static const char hex_table_uc[16] = { '0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'A', 'B',
'C', 'D', 'E', 'F' };
static const char hex_table_lc[16] = { '0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f' };
const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
for (i = 0; i < s; i++) {
buff[i * 2] = hex_table[src[i] >> 4];
buff[i * 2 + 1] = hex_table[src[i] & 0xF];
}
return buff;
if(src == NULL || len == 0 || des == NULL){
return NULL;
}
const char *hex_table = "0123456789ABCDEF";
for (int i=0; i<len; i++) {
des[i * 2] = hex_table[src[i] >> 4];
des[i * 2 + 1] = hex_table[src[i] & 0x0F];
}
return des;
}
int ff_hex_to_data(uint8_t* data, const char* p)

View file

@ -184,7 +184,7 @@ extern int ff_hex_to_data(uint8_t* data, const char* p);
/**
* convert data string to hex.
*/
extern char *ff_data_to_hex(char *buff, const uint8_t *src, int s, int lowercase);
extern char *srs_data_to_hex(char *buff, const uint8_t *src, int s);
/**
* generate the c0 chunk header for msg.