X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fimem.c;h=b6cd5890c2bbd6a4d1aa80c53c05fd25eff4ab93;hb=c60652e38ac6afd74bd8225e9dae5406f13aaa4f;hp=ab41aade581773f1438dfddf940d64f0327a74b2;hpb=0ef46dbedcab87a3100753407f70505479209638;p=vlc diff --git a/modules/access/imem.c b/modules/access/imem.c index ab41aade58..b6cd5890c2 100644 --- a/modules/access/imem.c +++ b/modules/access/imem.c @@ -115,6 +115,10 @@ static const char *cat_texts[] = { #define RELEASE_LONGTEXT N_(\ "Address of the release callback function") +#define SIZE_TEXT N_("Size") +#define SIZE_LONGTEXT N_(\ + "Size of stream in bytes") + vlc_module_begin() set_shortname(N_("Memory input")) set_description(N_("Memory input")) @@ -170,6 +174,10 @@ vlc_module_begin() change_private() change_safe() + add_integer ("imem-size", 0, NULL, SIZE_TEXT, SIZE_LONGTEXT, true) + change_private() + change_safe() + add_shortcut("imem") set_capability("access_demux", 0) set_callbacks(OpenDemux, CloseDemux) @@ -224,10 +232,6 @@ typedef struct { } imem_sys_t; static void ParseMRL(vlc_object_t *, const char *); -#define var_InheritRational(a,b,c,d) var_InheritRational(VLC_OBJECT(a),b,c,d) -static int (var_InheritRational)(vlc_object_t *, - unsigned *num, unsigned *den, - const char *var); /** * It closes the common part of the access and access_demux @@ -300,7 +304,7 @@ static int OpenAccess(vlc_object_t *object) access_t *access = (access_t *)object; imem_sys_t *sys; - if (OpenCommon(object, &sys, access->psz_path)) + if (OpenCommon(object, &sys, access->psz_location)) return VLC_EGENERIC; if (var_InheritInteger(object, "imem-cat") != 4) { @@ -315,6 +319,7 @@ static int OpenAccess(vlc_object_t *object) access->pf_block = Block; access->pf_seek = NULL; access->p_sys = (access_sys_t*)sys; + access->info.i_size = var_InheritInteger(object, "imem-size"); return VLC_SUCCESS; } @@ -408,7 +413,7 @@ static int OpenDemux(vlc_object_t *object) demux_t *demux = (demux_t *)object; imem_sys_t *sys; - if (OpenCommon(object, &sys, demux->psz_path)) + if (OpenCommon(object, &sys, demux->psz_location)) return VLC_EGENERIC; /* ES format */ @@ -440,13 +445,13 @@ static int OpenDemux(vlc_object_t *object) fmt.video.i_width = var_InheritInteger(object, "imem-width"); fmt.video.i_height = var_InheritInteger(object, "imem-height"); unsigned num, den; - if (!var_InheritRational(object, &num, &den, "imem-dar") && num > 0 && den > 0) { + if (!var_InheritURational(object, &num, &den, "imem-dar") && num > 0 && den > 0) { if (fmt.video.i_width > 0 && fmt.video.i_height > 0) { fmt.video.i_sar_num = num * fmt.video.i_height; fmt.video.i_sar_den = den * fmt.video.i_width; } } - if (!var_InheritRational(object, &num, &den, "imem-fps") && num > 0 && den > 0) { + if (!var_InheritURational(object, &num, &den, "imem-fps") && num > 0 && den > 0) { fmt.video.i_frame_rate = num; fmt.video.i_frame_rate_base = den; } @@ -610,55 +615,6 @@ static int Demux(demux_t *demux) return 1; } -/** - * It parses a rational number (it also accepts basic float number). - * - * It returns an error if the rational number cannot be parsed (0/0 is valid). - */ -static int (var_InheritRational)(vlc_object_t *object, - unsigned *num, unsigned *den, - const char *var) -{ - /* */ - *num = 0; - *den = 0; - - /* */ - char *tmp = var_InheritString(object, var); - if (!tmp) - goto error; - - char *next; - unsigned n = strtol(tmp, &next, 0); - unsigned d = strtol(*next ? &next[1] : "0", NULL, 0); - - if (*next == '.') { - /* Interpret as a float number */ - double r = us_atof(tmp); - double c = ceil(r); - if (c >= UINT_MAX) - goto error; - unsigned m = c; - if (m > 0) { - d = UINT_MAX / m; - n = r * d; - } else { - n = 0; - d = 0; - } - } - - if (n > 0 && d > 0) - vlc_ureduce(num, den, n, d, 0); - - free(tmp); - return VLC_SUCCESS; - -error: - free(tmp); - return VLC_EGENERIC; -} - /** * Parse the MRL and extract configuration from it. *