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:
parent
e9cb8210fc
commit
ac6b37de4b
3 changed files with 13 additions and 20 deletions
|
@ -771,7 +771,7 @@ srs_error_t SrsHlsMuxer::_refresh_m3u8(string m3u8_file)
|
||||||
{
|
{
|
||||||
string filename = req->stream+"-"+srs_int2str(segment->sequence_no)+".key";
|
string filename = req->stream+"-"+srs_int2str(segment->sequence_no)+".key";
|
||||||
char hexiv[33];
|
char hexiv[33];
|
||||||
ff_data_to_hex(hexiv,segment->iv,16,0);
|
srs_data_to_hex(hexiv,segment->iv,16);
|
||||||
hexiv[32] = '\0';
|
hexiv[32] = '\0';
|
||||||
string key_path;
|
string key_path;
|
||||||
//if key_url is not set,only use the file name
|
//if key_url is not set,only use the file name
|
||||||
|
|
|
@ -1051,25 +1051,18 @@ int srs_do_create_dir_recursively(string dir)
|
||||||
return c;
|
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;
|
if(src == NULL || len == 0 || des == NULL){
|
||||||
static const char hex_table_uc[16] = { '0', '1', '2', '3',
|
return NULL;
|
||||||
'4', '5', '6', '7',
|
}
|
||||||
'8', '9', 'A', 'B',
|
const char *hex_table = "0123456789ABCDEF";
|
||||||
'C', 'D', 'E', 'F' };
|
for (int i=0; i<len; i++) {
|
||||||
static const char hex_table_lc[16] = { '0', '1', '2', '3',
|
des[i * 2] = hex_table[src[i] >> 4];
|
||||||
'4', '5', '6', '7',
|
des[i * 2 + 1] = hex_table[src[i] & 0x0F];
|
||||||
'8', '9', 'a', 'b',
|
}
|
||||||
'c', 'd', 'e', 'f' };
|
|
||||||
const char *hex_table = lowercase ? hex_table_lc : hex_table_uc;
|
return des;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_hex_to_data(uint8_t* data, const char* p)
|
int ff_hex_to_data(uint8_t* data, const char* p)
|
||||||
|
|
|
@ -184,7 +184,7 @@ extern int ff_hex_to_data(uint8_t* data, const char* p);
|
||||||
/**
|
/**
|
||||||
* convert data string to hex.
|
* 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.
|
* generate the c0 chunk header for msg.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue