Skip to content

Commit

Permalink
Merge branch 'release0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
befovy committed Jan 6, 2020
2 parents d2168ab + fd80887 commit 12a2a74
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 45 deletions.
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
tag next
--------------------------------

tag f0.5.0 (2020-01-06)
--------------------------------
- feat: add option cover_after_prepared, show the first video as cover ([c64d2ab](https://github.com/befovy/ijkplayer/commit/c64d2ab5918468753630cb4e1e5364c0df9aecb2))
- feat: make start and pause available during async-preparing ([9e2ef17](https://github.com/befovy/ijkplayer/commit/9e2ef174096dfe0750a0030f4c2ec6a3f4fe847c))

tag f0.4.4
--------------------------------
- desktop: add libyuv for YUV2RGB
Expand Down
4 changes: 2 additions & 2 deletions android/ijkplayer/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=0.4.4
VERSION_CODE=000404
VERSION_NAME=0.5.0
VERSION_CODE=000500
GROUP=com.befovy.fijkplayer

# http://central.sonatype.org/pages/requirements.html
Expand Down
46 changes: 26 additions & 20 deletions ijkmedia/ijkplayer/ff_ffplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,20 +921,21 @@ static void video_image_display2(FFPlayer *ffp)
}
}
}
if (ffp->render_wait_start && !ffp->start_on_prepared && is->pause_req) {
if (!ffp->first_video_frame_rendered) {
ffp->first_video_frame_rendered = 1;
ffp_notify_msg1(ffp, FFP_MSG_VIDEO_RENDERING_START);
}
if (!ffp->first_video_frame_rendered && ffp->render_wait_start &&
!ffp->start_on_prepared && is->pause_req) {
ALOGI("render_wait_start wait first video render\n");
while (is->pause_req && !is->abort_request) {
SDL_Delay(20);
}
}
SDL_VoutDisplayYUVOverlay(ffp->vout, vp->bmp);
int ret = SDL_VoutDisplayYUVOverlay(ffp->vout, vp->bmp);
ffp->stat.vfps = SDL_SpeedSamplerAdd(&ffp->vfps_sampler, FFP_SHOW_VFPS_FFPLAY, "vfps[ffplay]");
if (!ffp->first_video_frame_rendered) {
ffp->first_video_frame_rendered = 1;
ffp_notify_msg1(ffp, FFP_MSG_VIDEO_RENDERING_START);
ALOGI("first video frame rendered, ret %d\n", ret);
if (ffp->cover_after_prepared && is->pause_req)
ffp_pause_l(ffp);
}

if (is->latest_video_seek_load_serial == vp->serial) {
Expand Down Expand Up @@ -1369,7 +1370,7 @@ static void video_refresh(FFPlayer *opaque, double *remaining_time)
if (lastvp->serial != vp->serial)
is->frame_timer = av_gettime_relative() / 1000000.0;

if (is->paused)
if (is->paused && (ffp->first_video_frame_rendered || !ffp->cover_after_prepared))
goto display;

/* compute nominal last_duration */
Expand Down Expand Up @@ -2727,10 +2728,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
set_clock_at(&is->audclk, is->audio_clock - (double)(is->audio_write_buf_size) / is->audio_tgt.bytes_per_sec - SDL_AoutGetLatencySeconds(ffp->aout), is->audio_clock_serial, ffp->audio_callback_time / 1000000.0);
sync_clock_to_slave(&is->extclk, &is->audclk);
}
if (!ffp->first_audio_frame_rendered) {
ffp->first_audio_frame_rendered = 1;
ffp_notify_msg1(ffp, FFP_MSG_AUDIO_RENDERING_START);
}


if (is->latest_audio_seek_load_serial == is->audio_clock_serial) {
#ifdef WIN32
Expand All @@ -2747,11 +2745,19 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
}
}

if (ffp->render_wait_start && !ffp->start_on_prepared && is->pause_req) {
if (!ffp->first_audio_frame_rendered && ffp->render_wait_start &&
!ffp->start_on_prepared && is->pause_req) {
ALOGI("render_wait_start wait first audio render\n");
while (is->pause_req && !is->abort_request) {
SDL_Delay(20);
}
}

if (!ffp->first_audio_frame_rendered) {
ffp->first_audio_frame_rendered = 1;
ffp_notify_msg1(ffp, FFP_MSG_AUDIO_RENDERING_START);
ALOGI("first audio frame rendered\n");
}
}

static int audio_open(FFPlayer *opaque, int64_t wanted_channel_layout, int wanted_nb_channels, int wanted_sample_rate, struct AudioParams *audio_hw_params)
Expand Down Expand Up @@ -2974,7 +2980,8 @@ static int stream_component_open(FFPlayer *ffp, int stream_index)
}
if ((ret = decoder_start(&is->auddec, audio_thread, ffp, "ff_audio_dec")) < 0)
goto out;
SDL_AoutPauseAudio(ffp->aout, 0);
if (!is->paused && !ffp->cover_after_prepared)
SDL_AoutPauseAudio(ffp->aout, 0);
break;
case AVMEDIA_TYPE_VIDEO:
is->video_stream = stream_index;
Expand Down Expand Up @@ -3357,7 +3364,7 @@ static int read_thread(void *arg)
if (ffp->infinite_buffer < 0 && is->realtime)
ffp->infinite_buffer = 1;

if (!ffp->render_wait_start && !ffp->start_on_prepared)
if (is->pause_req && !ffp->render_wait_start && !ffp->cover_after_prepared)
toggle_pause(ffp, 1);
if (is->video_st && is->video_st->codecpar) {
AVCodecParameters *codecpar = is->video_st->codecpar;
Expand All @@ -3366,15 +3373,11 @@ static int read_thread(void *arg)
}
ffp->prepared = true;
ffp_notify_msg1(ffp, FFP_MSG_PREPARED);
if (!ffp->render_wait_start && !ffp->start_on_prepared) {
while (is->pause_req && !is->abort_request &&
!ffp->render_wait_start && !ffp->start_on_prepared) {
if (!ffp->render_wait_start && !ffp->cover_after_prepared) {
while (is->pause_req && !is->abort_request) {
SDL_Delay(20);
}
}
if (is->pause_req && ffp->start_on_prepared) {
ffp->auto_resume = true;
}

if (ffp->auto_resume) {
ffp_notify_msg1(ffp, FFP_REQ_START);
Expand Down Expand Up @@ -3811,6 +3814,9 @@ static int video_refresh_thread(void *arg)
if (remaining_time > 0.0)
av_usleep((int)(int64_t)(remaining_time * 1000000.0));
remaining_time = REFRESH_RATE;
if (ffp->cover_after_prepared && !ffp->first_video_frame_rendered) {
is->force_refresh = true;
}
if (is->show_mode != SHOW_MODE_NONE && (!is->paused || is->force_refresh))
video_refresh(ffp, &remaining_time);
}
Expand Down
1 change: 1 addition & 0 deletions ijkmedia/ijkplayer/ff_ffplay_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ typedef struct FFPlayer {
char *mediacodec_default_name;
int ijkmeta_delay_init;
int render_wait_start;
int cover_after_prepared;
} FFPlayer;

#define fftime_to_milliseconds(ts) (av_rescale(ts, 1000, AV_TIME_BASE))
Expand Down
3 changes: 2 additions & 1 deletion ijkmedia/ijkplayer/ff_ffplay_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ static const AVOption ffp_context_options[] = {
OPTION_OFFSET(ijkmeta_delay_init), OPTION_INT(0, 0, 1) },
{ "render-wait-start", "render wait start",
OPTION_OFFSET(render_wait_start), OPTION_INT(0, 0, 1) },

{ "cover-after-prepared", "display the first video frame as cover, then toggle pause",
OPTION_OFFSET(cover_after_prepared), OPTION_INT(0, 0, 1) },
{ NULL }
};

Expand Down
31 changes: 14 additions & 17 deletions ijkmedia/ijkplayer/ijkplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ static int ikjmp_chkst_start_l(int mp_state)
{
MPST_RET_IF_EQ(mp_state, MP_STATE_IDLE);
MPST_RET_IF_EQ(mp_state, MP_STATE_INITIALIZED);
MPST_RET_IF_EQ(mp_state, MP_STATE_ASYNC_PREPARING);
// MPST_RET_IF_EQ(mp_state, MP_STATE_ASYNC_PREPARING);
// MPST_RET_IF_EQ(mp_state, MP_STATE_PREPARED);
// MPST_RET_IF_EQ(mp_state, MP_STATE_STARTED);
// MPST_RET_IF_EQ(mp_state, MP_STATE_PAUSED);
Expand All @@ -463,19 +463,11 @@ static int ikjmp_chkst_start_l(int mp_state)
static int ijkmp_start_l(IjkMediaPlayer *mp)
{
assert(mp);
int retval = 0;
if (mp->mp_state == MP_STATE_ASYNC_PREPARING) {
mp->ffplayer->start_on_prepared = 1;
retval = 0;
} else {
retval = ikjmp_chkst_start_l(mp->mp_state);
if (retval == 0) {
ffp_remove_msg(mp->ffplayer, FFP_REQ_START);
ffp_remove_msg(mp->ffplayer, FFP_REQ_PAUSE);
ffp_notify_msg1(mp->ffplayer, FFP_REQ_START);
}
}
return retval;
MP_RET_IF_FAILED(ikjmp_chkst_start_l(mp->mp_state));
ffp_remove_msg(mp->ffplayer, FFP_REQ_START);
ffp_remove_msg(mp->ffplayer, FFP_REQ_PAUSE);
ffp_notify_msg1(mp->ffplayer, FFP_REQ_START);
return 0;
}

int ijkmp_start(IjkMediaPlayer *mp)
Expand All @@ -493,7 +485,7 @@ static int ikjmp_chkst_pause_l(int mp_state)
{
MPST_RET_IF_EQ(mp_state, MP_STATE_IDLE);
MPST_RET_IF_EQ(mp_state, MP_STATE_INITIALIZED);
MPST_RET_IF_EQ(mp_state, MP_STATE_ASYNC_PREPARING);
// MPST_RET_IF_EQ(mp_state, MP_STATE_ASYNC_PREPARING);
// MPST_RET_IF_EQ(mp_state, MP_STATE_PREPARED);
// MPST_RET_IF_EQ(mp_state, MP_STATE_STARTED);
// MPST_RET_IF_EQ(mp_state, MP_STATE_PAUSED);
Expand Down Expand Up @@ -737,7 +729,7 @@ int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block)
// FIXME: 1: onError() ?
av_log(mp->ffplayer, AV_LOG_DEBUG, "FFP_MSG_PREPARED: expecting mp_state==MP_STATE_ASYNC_PREPARING\n");
}
if (!mp->ffplayer->start_on_prepared) {
if (mp->ffplayer->is && mp->ffplayer->is->pause_req) {
ijkmp_change_state_l(mp, MP_STATE_PAUSED);
} else {
ijkmp_change_state_l(mp, MP_STATE_STARTED);
Expand Down Expand Up @@ -784,6 +776,9 @@ int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block)
}
mp->restart = 0;
mp->restart_from_beginning = 0;
} else if(mp->mp_state == MP_STATE_ASYNC_PREPARING) {
av_log(mp->ffplayer, AV_LOG_DEBUG, "ijkmp_get_msg: FFP_REQ_START: start from async preparing\n");
ffp_start_l(mp->ffplayer);
} else {
av_log(mp->ffplayer, AV_LOG_DEBUG, "ijkmp_get_msg: FFP_REQ_START: start on fly\n");
retval = ffp_start_l(mp->ffplayer);
Expand All @@ -798,7 +793,9 @@ int ijkmp_get_msg(IjkMediaPlayer *mp, AVMessage *msg, int block)
MPTRACE("ijkmp_get_msg: FFP_REQ_PAUSE\n");
continue_wait_next_msg = 1;
pthread_mutex_lock(&mp->mutex);
if (0 == ikjmp_chkst_pause_l(mp->mp_state)) {
if (mp->mp_state == MP_STATE_ASYNC_PREPARING) {
ffp_pause_l(mp->ffplayer);
} else if (0 == ikjmp_chkst_pause_l(mp->mp_state)) {
int pause_ret = ffp_pause_l(mp->ffplayer);
if (pause_ret == 0)
ijkmp_change_state_l(mp, MP_STATE_PAUSED);
Expand Down
4 changes: 2 additions & 2 deletions ios/CocoaPodsPub/FIJKPlayer.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |spec|
#

spec.name = "FIJKPlayer"
spec.version = "0.4.4"
spec.version = "0.5.0"
spec.summary = "ijkplayer iOS video player SDK"

spec.author = { "befovy" => "befovy@gmail.com" }
Expand Down Expand Up @@ -75,7 +75,7 @@ Pod::Spec.new do |spec|
# Supports git, hg, bzr, svn and HTTP.
#

spec.source = { :http => "https://github.com/befovy/ijkplayer/releases/download/f0.4.4/IJKPlayer.tar.gz" }
spec.source = { :http => "https://github.com/befovy/ijkplayer/releases/download/f0.5.0/IJKPlayer.tar.gz" }
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
Expand Down
4 changes: 2 additions & 2 deletions ios/IJKMediaDemo/IJKMediaDemo/IJKMediaDemo-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.4.4</string>
<string>0.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>000404</string>
<string>000500</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIFileSharingEnabled</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "ijkplayer/ijkplayer.h"
#include "ijkplayer.h"
#import "IJKSDLGLView.h"

#if IJK_IOS
Expand Down

0 comments on commit 12a2a74

Please sign in to comment.