61 lines
1.6 KiB
C++
61 lines
1.6 KiB
C++
|
|
/***************************************************************************************
|
||
|
|
*
|
||
|
|
* IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||
|
|
*
|
||
|
|
* By downloading, copying, installing or using the software you agree to this license.
|
||
|
|
* If you do not agree to this license, do not download, install,
|
||
|
|
* copy or use the software.
|
||
|
|
*
|
||
|
|
* Copyright (C) 2014-2024, Happytimesoft Corporation, all rights reserved.
|
||
|
|
*
|
||
|
|
* Redistribution and use in binary forms, with or without modification, are permitted.
|
||
|
|
*
|
||
|
|
* Unless required by applicable law or agreed to in writing, software distributed
|
||
|
|
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||
|
|
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
|
||
|
|
* language governing permissions and limitations under the License.
|
||
|
|
*
|
||
|
|
****************************************************************************************/
|
||
|
|
|
||
|
|
#include "sys_inc.h"
|
||
|
|
#include "rtp.h"
|
||
|
|
|
||
|
|
|
||
|
|
uint16 rtp_read_uint16(uint8 *input)
|
||
|
|
{
|
||
|
|
return (uint16)((input[0] << 8) | input[1]);
|
||
|
|
}
|
||
|
|
|
||
|
|
uint32 rtp_read_uint32(uint8 *input)
|
||
|
|
{
|
||
|
|
return (uint32)((input[0] << 24) | (input[1] << 16) | (input[2] << 8) | input[3]);
|
||
|
|
}
|
||
|
|
|
||
|
|
uint64 rtp_read_uint64(uint8 *input)
|
||
|
|
{
|
||
|
|
uint32 low = rtp_read_uint32(input);
|
||
|
|
uint32 high = rtp_read_uint32(input+4);
|
||
|
|
return (uint64)(((uint64)low) << 32 | high);
|
||
|
|
}
|
||
|
|
|
||
|
|
int rtp_write_uint16(uint8 *output, uint16 nVal)
|
||
|
|
{
|
||
|
|
output[1] = nVal & 0xff;
|
||
|
|
output[0] = nVal >> 8;
|
||
|
|
|
||
|
|
return 2;
|
||
|
|
}
|
||
|
|
|
||
|
|
int rtp_write_uint32(uint8 *output, uint32 nVal)
|
||
|
|
{
|
||
|
|
output[3] = nVal & 0xff;
|
||
|
|
output[2] = nVal >> 8;
|
||
|
|
output[1] = nVal >> 16;
|
||
|
|
output[0] = nVal >> 24;
|
||
|
|
|
||
|
|
return 4;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|