UTFstring / C string conversion. Proper version numbers are written to the KaxInfos.

This commit is contained in:
Moritz Bunkus 2003-05-21 21:05:47 +00:00
parent 1a4f103fa1
commit fbc60f9089
4 changed files with 60 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2003-05-21 Moritz Bunkus <moritz@bunkus.org>
* Some internal changes and enhancements. Code requires libebml
and libmatroska 0.4.3 now.
2003-05-19 Moritz Bunkus <moritz@bunkus.org>
* ADTS headers are stripped from the AAC streams. This is what I'd

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: common.cpp,v 1.23 2003/05/19 18:24:52 mosu Exp $
\version \$Id: common.cpp,v 1.24 2003/05/21 21:05:47 mosu Exp $
\brief helper functions, common variables
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -343,3 +343,47 @@ void *_saferealloc(void *mem, size_t size, const char *file, int line) {
return mem;
}
/*
* UTFstring <-> C string conversion
*/
UTFstring cstr_to_UTFstring(const char *c) {
#ifdef NO_WSTRING
return UTFstring(c);
#else
wchar_t *new_string;
const char *sptr;
UTFstring u;
int len;
len = strlen(c);
new_string = (wchar_t *)safemalloc((len + 1) * sizeof(wchar_t));
memset(new_string, 0, (len + 1) * sizeof(wchar_t));
new_string[len] = L'\0';
sptr = c;
mbsrtowcs(new_string, &sptr, len, NULL);
u = UTFstring(new_string);
safefree(new_string);
return u;
#endif
}
char *UTFstring_to_cstr(const UTFstring &u) {
#ifdef NO_WSTRING
return safestrdup(u.c_str());
#else
const wchar_t *sptr;
char *new_string;
int len;
len = u.size();
new_string = (char *)safemalloc(len * 4 + 1);
memset(new_string, 0, len * 4 + 1);
sptr = u.c_str();
wcsrtombs(new_string, &sptr, len, NULL);
return new_string;
#endif
}

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: common.h,v 1.27 2003/05/20 06:30:24 mosu Exp $
\version \$Id: common.h,v 1.28 2003/05/21 21:05:47 mosu Exp $
\brief definitions used in all programs, helper functions
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -36,6 +36,8 @@
#define nice(a)
#endif
#include "EbmlUnicodeString.h"
#include "config.h"
#define VERSIONINFO "mkvmerge v" VERSION
@ -105,6 +107,9 @@ void *_safememdup(const void *src, size_t size, const char *file, int line);
#define saferealloc(mem, size) _saferealloc(mem, size, __FILE__, __LINE__)
void *_saferealloc(void *mem, size_t size, const char *file, int line);
UTFstring cstr_to_UTFstring(const char *c);
char *UTFstring_to_cstr(const UTFstring &u);
extern int verbose;
class bit_cursor_c {

View File

@ -13,7 +13,7 @@
/*!
\file
\version \$Id: mkvmerge.cpp,v 1.70 2003/05/21 19:55:49 mosu Exp $
\version \$Id: mkvmerge.cpp,v 1.71 2003/05/21 21:05:47 mosu Exp $
\brief command line parameter parsing, looping, output handling
\author Moritz Bunkus <moritz@bunkus.org>
*/
@ -583,10 +583,11 @@ static void render_headers(mm_io_callback *out) {
kax_duration = &GetChild<KaxDuration>(*kax_infos);
*(static_cast<EbmlFloat *>(kax_duration)) = 0.0;
string version = string("libmatroska ") + KaxCodeVersion;
*((EbmlUnicodeString *)&GetChild<KaxMuxingApp>(*kax_infos)) =
L"libmatroska 0.4.3";
cstr_to_UTFstring(version.c_str());
*((EbmlUnicodeString *)&GetChild<KaxWritingApp>(*kax_infos)) =
L"mkvmerge 0.3.4";
cstr_to_UTFstring(VERSIONINFO);
#if LIBEBML_VERSION >= 000403
kax_segment->WriteHead(*out, 5);