1 /* 2 * Copyright 2015 Rockchip Electronics Co. LTD 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #define MODULE_TAG "mpp_packet_test" 18 19 #include <stdlib.h> 20 21 #include "mpp_log.h" 22 #include "mpp_packet.h" 23 24 #define MPP_PACKET_TEST_SIZE 1024 25 main()26int main() 27 { 28 MPP_RET ret = MPP_ERR_UNKNOW; 29 MppPacket packet = NULL; 30 void *data = NULL; 31 size_t size = MPP_PACKET_TEST_SIZE; 32 33 mpp_log("mpp_packet_test start\n"); 34 35 data = malloc(size); 36 if (NULL == data) { 37 mpp_err("mpp_packet_test malloc failed\n"); 38 goto MPP_PACKET_failed; 39 } 40 41 ret = mpp_packet_init(&packet, data, size); 42 if (MPP_OK != ret) { 43 mpp_err("mpp_packet_test mpp_packet_init failed\n"); 44 goto MPP_PACKET_failed; 45 } 46 mpp_packet_set_eos(packet); 47 if (MPP_OK != ret) { 48 mpp_err("mpp_packet_test mpp_packet_set_eos failed\n"); 49 goto MPP_PACKET_failed; 50 } 51 mpp_packet_deinit(&packet); 52 53 free(data); 54 mpp_log("mpp_packet_test success\n"); 55 return ret; 56 57 MPP_PACKET_failed: 58 if (packet) 59 mpp_packet_deinit(&packet); 60 61 if (data) 62 free(data); 63 64 mpp_log("mpp_packet_test failed\n"); 65 return ret; 66 } 67 68