]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/sdl2.c
Merge commit '325aa63dd1a3abc2453914d0bc111d297833d725'
[ffmpeg] / libavdevice / sdl2.c
index 48ed977bebd3518e0cdc3eaafff4419e5e97a0ef..da5143078eef8b5d3121dd533d40e91d4e325eba 100644 (file)
@@ -42,6 +42,7 @@ typedef struct {
     int window_width, window_height;  /**< size of the window */
     int window_fullscreen;
     int window_borderless;
+    int enable_quit_action;
 
     SDL_Texture *texture;
     int texture_fmt;
@@ -206,9 +207,7 @@ static int sdl2_write_header(AVFormatContext *s)
         }
     }
 
-    sdl->window_width = sdl->texture_rect.w = codecpar->width;
-    sdl->window_height = sdl->texture_rect.h = codecpar->height;
-    sdl->texture_rect.x = sdl->texture_rect.y = 0;
+    compute_texture_rect(s);
 
     if (SDL_CreateWindowAndRenderer(sdl->window_width, sdl->window_height,
                                     flags, &sdl->window, &sdl->renderer) != 0){
@@ -219,7 +218,7 @@ static int sdl2_write_header(AVFormatContext *s)
     SDL_SetWindowTitle(sdl->window, sdl->window_title);
 
     sdl->texture = SDL_CreateTexture(sdl->renderer, sdl->texture_fmt, SDL_TEXTUREACCESS_STREAMING,
-                                     sdl->window_width, sdl->window_height);
+                                     codecpar->width, codecpar->height);
 
     if (!sdl->texture) {
         av_log(sdl, AV_LOG_ERROR, "Unable to set create mode: %s\n", SDL_GetError());
@@ -279,7 +278,7 @@ static int sdl2_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
-    if (quit) {
+    if (quit && sdl->enable_quit_action) {
         sdl2_write_trailer(s);
         return AVERROR(EIO);
     }
@@ -340,6 +339,7 @@ static const AVOption options[] = {
     { "window_size",       "set SDL window forced size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM },
     { "window_fullscreen", "set SDL window fullscreen",  OFFSET(window_fullscreen), AV_OPT_TYPE_BOOL,  { .i64 = 0 },    0, 1, AV_OPT_FLAG_ENCODING_PARAM },
     { "window_borderless", "set SDL window border off",  OFFSET(window_borderless), AV_OPT_TYPE_BOOL,  { .i64 = 0 },    0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+    { "window_enable_quit", "set if quit action is available", OFFSET(enable_quit_action), AV_OPT_TYPE_INT, {.i64=1},   0, 1, AV_OPT_FLAG_ENCODING_PARAM },
     { NULL },
 };