Re: [FFmpeg-devel] [PATCH 1/2] ffplay: create the window and the renderer before starting playback

2017-11-04 Thread Marton Balint



On Sun, 29 Oct 2017, Marton Balint wrote:




On Sat, 28 Oct 2017, Clément Bœsch wrote:


On Sat, Oct 28, 2017 at 11:05:15PM +0200, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
 fftools/ffplay.c | 67 

+---

 1 file changed, 35 insertions(+), 32 deletions(-)



Won't this prevent using ffplay without a display? Think of playing audio
with ffplay on a headless machine (no display server).


No, for that, the user have to use -nodisp, and it should work the 
same way as before, because the window/renderer creating code is in an if 
(!display_disable) {...} block.


Applied the series.

Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] ffplay: create the window and the renderer before starting playback

2017-10-28 Thread Marton Balint



On Sat, 28 Oct 2017, Clément Bœsch wrote:


On Sat, Oct 28, 2017 at 11:05:15PM +0200, Marton Balint wrote:

Signed-off-by: Marton Balint 
---
 fftools/ffplay.c | 67 +---
 1 file changed, 35 insertions(+), 32 deletions(-)



Won't this prevent using ffplay without a display? Think of playing audio
with ffplay on a headless machine (no display server).


No, for that, the user have to use -nodisp, and it should work the 
same way as before, because the window/renderer creating code is in an if 
(!display_disable) {...} block.


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] ffplay: create the window and the renderer before starting playback

2017-10-28 Thread Clément Bœsch
On Sat, Oct 28, 2017 at 11:05:15PM +0200, Marton Balint wrote:
> Signed-off-by: Marton Balint 
> ---
>  fftools/ffplay.c | 67 
> +---
>  1 file changed, 35 insertions(+), 32 deletions(-)
> 

Won't this prevent using ffplay without a display? Think of playing audio
with ffplay on a headless machine (no display server).

[...]

-- 
Clément B.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] ffplay: create the window and the renderer before starting playback

2017-10-28 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 fftools/ffplay.c | 67 +---
 1 file changed, 35 insertions(+), 32 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 8e88a77820..bebc2b392b 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -361,6 +361,7 @@ static AVPacket flush_pkt;
 
 static SDL_Window *window;
 static SDL_Renderer *renderer;
+static SDL_RendererInfo renderer_info = {0};
 
 static const struct TextureFormatEntry {
 enum AVPixelFormat format;
@@ -1320,38 +1321,15 @@ static int video_open(VideoState *is)
 h = default_height;
 }
 
-if (!window) {
-int flags = SDL_WINDOW_SHOWN;
-if (!window_title)
-window_title = input_filename;
-if (is_full_screen)
-flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
-if (borderless)
-flags |= SDL_WINDOW_BORDERLESS;
-else
-flags |= SDL_WINDOW_RESIZABLE;
-window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED, 
SDL_WINDOWPOS_UNDEFINED, w, h, flags);
-SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
-if (window) {
-SDL_RendererInfo info;
-renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED 
| SDL_RENDERER_PRESENTVSYNC);
-if (!renderer) {
-av_log(NULL, AV_LOG_WARNING, "Failed to initialize a hardware 
accelerated renderer: %s\n", SDL_GetError());
-renderer = SDL_CreateRenderer(window, -1, 0);
-}
-if (renderer) {
-if (!SDL_GetRendererInfo(renderer, &info))
-av_log(NULL, AV_LOG_VERBOSE, "Initialized %s renderer.\n", 
info.name);
-}
-}
-} else {
-SDL_SetWindowSize(window, w, h);
-}
+if (!window_title)
+window_title = input_filename;
+SDL_SetWindowTitle(window, window_title);
 
-if (!window || !renderer) {
-av_log(NULL, AV_LOG_FATAL, "SDL: could not set video mode - 
exiting\n");
-do_exit(is);
-}
+SDL_SetWindowSize(window, w, h);
+SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, 
SDL_WINDOWPOS_CENTERED);
+if (is_full_screen)
+SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
+SDL_ShowWindow(window);
 
 is->width  = w;
 is->height = h;
@@ -1362,7 +1340,7 @@ static int video_open(VideoState *is)
 /* display the current picture, if any */
 static void video_display(VideoState *is)
 {
-if (!window)
+if (!is->width)
 video_open(is);
 
 SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
@@ -3744,6 +3722,31 @@ int main(int argc, char **argv)
 av_init_packet(&flush_pkt);
 flush_pkt.data = (uint8_t *)&flush_pkt;
 
+if (!display_disable) {
+int flags = SDL_WINDOW_HIDDEN;
+if (borderless)
+flags |= SDL_WINDOW_BORDERLESS;
+else
+flags |= SDL_WINDOW_RESIZABLE;
+window = SDL_CreateWindow(program_name, SDL_WINDOWPOS_UNDEFINED, 
SDL_WINDOWPOS_UNDEFINED, default_width, default_height, flags);
+SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
+if (window) {
+renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED 
| SDL_RENDERER_PRESENTVSYNC);
+if (!renderer) {
+av_log(NULL, AV_LOG_WARNING, "Failed to initialize a hardware 
accelerated renderer: %s\n", SDL_GetError());
+renderer = SDL_CreateRenderer(window, -1, 0);
+}
+if (renderer) {
+if (!SDL_GetRendererInfo(renderer, &renderer_info))
+av_log(NULL, AV_LOG_VERBOSE, "Initialized %s renderer.\n", 
renderer_info.name);
+}
+}
+if (!window || !renderer) {
+av_log(NULL, AV_LOG_FATAL, "Failed to create window or renderer: 
%s", SDL_GetError());
+exit(1);
+}
+}
+
 is = stream_open(input_filename, file_iformat);
 if (!is) {
 av_log(NULL, AV_LOG_FATAL, "Failed to initialize VideoState!\n");
-- 
2.13.6

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel