Skip to content

Commit

Permalink
remove video_out_type flag, and remove unuse code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Apr 18, 2012
1 parent 3ffdf68 commit 7c77afe
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 33 deletions.
4 changes: 2 additions & 2 deletions avcore/avplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ BOOL avplayer::subclasswindow(HWND hwnd, BOOL in_process/* = TRUE*/)
return m_impl->subclasswindow(hwnd, in_process);
}

BOOL avplayer::open(LPCTSTR movie, int media_type, int video_out_type/* = 0*/)
BOOL avplayer::open(LPCTSTR movie, int media_type)
{
return m_impl->open(movie, media_type, video_out_type);
return m_impl->open(movie, media_type);
}

BOOL avplayer::play(int index /*= 0*/)
Expand Down
2 changes: 1 addition & 1 deletion avcore/avplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class EXPORT_API avplayer
// 也可以是MEDIA_TYPE_BT, 注意, 这个函数只打开文件, 但并不播放.
// 重新打开文件前, 必须关闭之前的媒体文件, 否则可能产生内存泄漏!
// 另外, 在播放前, avplayer必须拥有一个窗口.
BOOL open(LPCTSTR movie, int media_type, int video_out_type = 0);
BOOL open(LPCTSTR movie, int media_type);

// 播放索引为index的文件, index表示在播放列表中的
// 位置计数, 从0开始计算, index主要用于播放多文件的bt
Expand Down
17 changes: 2 additions & 15 deletions avcore/player_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,25 +533,12 @@ void player_impl::init_video(video_render *vo)
break;
}

ret = ogl_init_video(&ctx, (void*)m_hwnd, 10, 10, PIX_FMT_YUV420P);
ogl_destory_render(ctx);
if (ret == 0)
{
vo->init_video = ogl_init_video;
vo->render_one_frame = ogl_render_one_frame;
vo->re_size = ogl_re_size;
vo->aspect_ratio = ogl_aspect_ratio;
vo->use_overlay = ogl_use_overlay;
vo->destory_video = ogl_destory_render;
break;
}

// 表示视频渲染器初始化失败!!!
assert(0);
} while (0);
}

BOOL player_impl::open(LPCTSTR movie, int media_type, int video_out_type/* = 0*/)
BOOL player_impl::open(LPCTSTR movie, int media_type)
{
// 如果未关闭原来的媒体, 则返回失败.
if (m_avplay || m_source)
Expand Down Expand Up @@ -647,7 +634,7 @@ BOOL player_impl::open(LPCTSTR movie, int media_type, int video_out_type/* = 0*/
}

// 初始化avplay.
if (initialize(m_avplay, m_source, video_out_type) != 0)
if (initialize(m_avplay, m_source) != 0)
break;

// 如果是bt类型, 则在此得到视频文件列表, 并添加到m_media_list.
Expand Down
2 changes: 1 addition & 1 deletion avcore/player_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class player_impl
// 也可以是MEDIA_TYPE_BT, 注意, 这个函数只打开文件, 但并不播放.
// 重新打开文件前, 必须关闭之前的媒体文件, 否则可能产生内存泄漏!
// 另外, 在播放前, avplayer必须拥有一个窗口.
BOOL open(LPCTSTR movie, int media_type, int video_out_type = 0);
BOOL open(LPCTSTR movie, int media_type);

// 播放索引为index的文件, index表示在播放列表中的
// 位置计数, 从0开始计算, index主要用于播放多文件的bt
Expand Down
28 changes: 20 additions & 8 deletions libav/src/avplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void free_video_render(video_render *render)
free(render);
}

int initialize(avplay *play, media_source *ms, int video_out_type)
int initialize(avplay *play, media_source *ms)
{
int ret = 0, i = 0;
AVInputFormat *iformat = NULL;
Expand All @@ -496,8 +496,6 @@ int initialize(avplay *play, media_source *ms, int video_out_type)

/* 保存media_source指针并初始化, 由avplay负责管理释放其内存. */
play->m_media_source = ms;
/* 保存视频输出类型. */
play->m_video_render_type = video_out_type;

/* 初始化数据源. */
if (play->m_media_source->init_source &&
Expand Down Expand Up @@ -734,19 +732,33 @@ int start(avplay *play, int index)
return 0;
}

void configure(avplay *play, void* render, int type)
void configure(avplay *play, void* param, int type)
{
if (type == AUDIO_RENDER)
{
if (play->m_audio_render)
if (play->m_audio_render && play->m_audio_render->ctx)
play->m_audio_render->destory_audio(play->m_audio_render->ctx);
play->m_audio_render = render;
play->m_audio_render = param;
}
if (type == VIDEO_RENDER)
{
if (play->m_video_render)
if (play->m_video_render && play->m_video_render->ctx)
play->m_video_render->destory_video(play->m_video_render->ctx);
play->m_video_render = render;
play->m_video_render = param;
}
if (type == MEDIA_SOURCE)
{
/* 注意如果正在播放, 则不可以配置应该源. */
if (play->m_play_status == playing ||
play->m_play_status == paused)
return ;
if (play->m_media_source)
{
if (play->m_media_source && play->m_media_source->ctx)
play->m_media_source->close(play->m_media_source->ctx);
free_media_source(play->m_media_source);
play->m_media_source = param;
}
}
}

Expand Down
9 changes: 3 additions & 6 deletions libav/src/avplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ typedef struct avplay
audio_render *m_audio_render;
/* 当前视频渲染器. */
video_render *m_video_render;
/* 当前渲染器的类型. */
int m_video_render_type;

/* 当前音频播放buffer大小. */
uint32_t m_audio_buf_size;
Expand Down Expand Up @@ -278,7 +276,6 @@ EXPORT_API void free_avplay_context(avplay *ctx);
* Initialize the player.
* @param play pointer to user-supplied avplayer (allocated by alloc_avplay_context).
* @param filename filename Name of the stream to open.
* @param video_out_type expression BT or FILE.
* @return 0 on success, a negative AVERROR on failure.
* example:
* avplayer* play = alloc_avplay_context();
Expand All @@ -288,16 +285,16 @@ EXPORT_API void free_avplay_context(avplay *ctx);
* if (ret != 0)
* return ret; // ERROR!
*/
EXPORT_API int initialize(avplay *play, media_source *ms, int video_out_type);
EXPORT_API int initialize(avplay *play, media_source *ms);

/*
* The Configure render or source to palyer.
* @param play pointer to the player.
* @param render video render or audio render.
* @param param video render or audio render or media_source.
* @param type Specifies render type, MEDIA_SOURCE or AUDIO_RENDER VIDEO_RENDER.
* @This function does not return a value.
*/
EXPORT_API void configure(avplay *play, void *render, int type);
EXPORT_API void configure(avplay *play, void *param, int type);

/*
* The start action player to play.
Expand Down

0 comments on commit 7c77afe

Please sign in to comment.