1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2013-2014 L-SMASH project
6 * Authors: Yusuke Nakamura <muken.the.vfrmaniac@gmail.com>
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 *****************************************************************************/
21 /* This file is available under an ISC license. */
23 #include "common/internal.h" /* must be placed first */
29 #define WIN32_LEAN_AND_MEAN
34 void lsmash_get_mainargs( int *argc
, char ***argv
)
36 struct SI
{ int newmode
; } si
= { 0 };
37 int __wgetmainargs( int *, wchar_t ***, wchar_t ***, int, struct SI
* );
38 wchar_t **wargv
, **envp
;
39 __wgetmainargs( argc
, &wargv
, &envp
, 1, &si
);
40 *argv
= lsmash_malloc_zero( (*argc
+ 1) * sizeof(char *) );
41 for( int i
= 0; i
< *argc
; ++i
)
42 lsmash_string_from_wchar( CP_UTF8
, wargv
[i
], &(*argv
)[i
] );
46 int lsmash_write_lsmash_indicator( lsmash_root_t
*root
)
48 /* Write a tag in a free space to indicate the output file is written by L-SMASH. */
49 char *string
= "Multiplexed by L-SMASH";
50 int length
= strlen( string
);
51 lsmash_box_type_t type
= lsmash_form_iso_box_type( LSMASH_4CC( 'f', 'r', 'e', 'e' ) );
52 lsmash_box_t
*free_box
= lsmash_create_box( type
, (uint8_t *)string
, length
, LSMASH_BOX_PRECEDENCE_N
);
55 if( lsmash_add_box_ex( lsmash_root_as_box( root
), &free_box
) < 0 )
57 lsmash_destroy_box( free_box
);
60 return lsmash_write_top_level_box( free_box
);