PLAYER_INSTANCE_CHECK(player);
PLAYER_NULL_ARG_CHECK(packet);
int ret = PLAYER_ERROR_NONE;
+ int packet_ret = MEDIA_PACKET_ERROR_NONE;
player_cli_s *pc = (player_cli_s *)player;
muse_player_api_e api = MUSE_PLAYER_API_PUSH_MEDIA_STREAM;
char *ret_buf = NULL;
LOGD("ENTER");
- media_packet_get_buffer_data_ptr(packet, (void **)&buf);
- media_packet_get_buffer_size(packet, &push_media.size);
- media_packet_get_pts(packet, &push_media.pts);
- media_packet_get_format(packet, &format);
- media_packet_get_flags(packet, &push_media.flags);
- if (media_packet_get_codec_data(packet, (void **)&codec_data, &codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
- if (codec_data_size > 0 && codec_data_size <= sizeof(push_media.codec_data))
- memcpy(push_media.codec_data, codec_data, codec_data_size);
+ if(media_packet_get_buffer_data_ptr(packet, (void **)&buf) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get buffer data ptr");
+ return PLAYER_ERROR_INVALID_OPERATION;
}
- push_media.codec_data_size = codec_data_size;
- push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
+ if(media_packet_get_buffer_size(packet, &push_media.size) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get buffer size");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if(media_packet_get_pts(packet, &push_media.pts) != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get buffer pts");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
- media_packet_is_video(packet, &is_video);
- media_packet_is_audio(packet, &is_audio);
- media_packet_is_end_of_stream(packet, &is_eos);
+ if(media_packet_get_format(packet, &format) != MEDIA_PACKET_ERROR_NONE) { /* format ref count is increased */
+ LOGE("failed to get media format");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ packet_ret = media_packet_get_flags(packet, &push_media.flags);
+ packet_ret |= media_packet_is_video(packet, &is_video);
+ packet_ret |= media_packet_is_audio(packet, &is_audio);
+ packet_ret |= media_packet_is_end_of_stream(packet, &is_eos);
if (is_video)
- media_format_get_video_info(format, &push_media.mimetype, &push_media.width, &push_media.height, NULL, NULL);
+ packet_ret |= media_format_get_video_info(format, &push_media.mimetype, &push_media.width, &push_media.height, NULL, NULL);
else if (is_audio)
- media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
+ packet_ret |= media_format_get_audio_info(format, &push_media.mimetype, NULL, NULL, NULL, NULL);
media_format_unref(format);
+ if (packet_ret != MEDIA_PACKET_ERROR_NONE) {
+ LOGE("failed to get media packet info");
+ return PLAYER_ERROR_INVALID_OPERATION;
+ }
+
+ if (media_packet_get_codec_data(packet, (void **)&codec_data, &codec_data_size) == MEDIA_PACKET_ERROR_NONE) {
+ if (codec_data_size > 0 && codec_data_size <= sizeof(push_media.codec_data))
+ memcpy(push_media.codec_data, codec_data, codec_data_size);
+ }
+
+ push_media.codec_data_size = codec_data_size;
+ push_media.buf_type = PUSH_MEDIA_BUF_TYPE_RAW;
+
#ifdef __UN_USED
int arr_buf_len = 0;