Commit 4592edcb authored by Aymeric Moizard's avatar Aymeric Moizard
Browse files

fix to use UTF-8 format for filename in windows player & recorder.

parent 725a8b65
No related merge requests found
Showing with 15 additions and 17 deletions
...@@ -17,11 +17,12 @@ along with this program; if not, write to the Free Software ...@@ -17,11 +17,12 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#define UNICODE
#include "mediastreamer2/msfileplayer.h" #include "mediastreamer2/msfileplayer.h"
#include "mediastreamer2/waveheader.h" #include "mediastreamer2/waveheader.h"
#include "mediastreamer2/msticker.h" #include "mediastreamer2/msticker.h"
typedef enum { typedef enum {
CLOSED, CLOSED,
STARTED, STARTED,
...@@ -128,13 +129,10 @@ static int player_open(MSFilter *f, void *arg){ ...@@ -128,13 +129,10 @@ static int player_open(MSFilter *f, void *arg){
PlayerData *d=(PlayerData*)f->data; PlayerData *d=(PlayerData*)f->data;
HANDLE fd; HANDLE fd;
const char *file=(const char*)arg; const char *file=(const char*)arg;
#if defined(_WIN32_WCE) WCHAR wUnicode[1024];
fd = CreateFile((LPCWSTR)file, GENERIC_READ, FILE_SHARE_READ, NULL, MultiByteToWideChar(CP_UTF8, 0, file, -1, wUnicode, 1024);
fd = CreateFile(wUnicode, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL); OPEN_EXISTING, 0, NULL);
#else
fd = CreateFile(file, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL);
#endif
if (fd==INVALID_HANDLE_VALUE){ if (fd==INVALID_HANDLE_VALUE){
ms_warning("Failed to open %s",file); ms_warning("Failed to open %s",file);
return -1; return -1;
......
...@@ -17,6 +17,8 @@ along with this program; if not, write to the Free Software ...@@ -17,6 +17,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#define UNICODE
#include "mediastreamer2/msfilerec.h" #include "mediastreamer2/msfilerec.h"
#include "mediastreamer2/waveheader.h" #include "mediastreamer2/waveheader.h"
...@@ -84,6 +86,9 @@ static void write_wav_header(int rate,int size, char *filename){ ...@@ -84,6 +86,9 @@ static void write_wav_header(int rate,int size, char *filename){
wave_header_t header; wave_header_t header;
DWORD bytes_written=0; DWORD bytes_written=0;
HANDLE fd; HANDLE fd;
WCHAR wUnicode[1024];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wUnicode, 1024);
memcpy(&header.riff_chunk.riff,"RIFF",4); memcpy(&header.riff_chunk.riff,"RIFF",4);
header.riff_chunk.len=le_uint32(size+32); header.riff_chunk.len=le_uint32(size+32);
memcpy(&header.riff_chunk.wave,"WAVE",4); memcpy(&header.riff_chunk.wave,"WAVE",4);
...@@ -101,11 +106,7 @@ static void write_wav_header(int rate,int size, char *filename){ ...@@ -101,11 +106,7 @@ static void write_wav_header(int rate,int size, char *filename){
header.data_chunk.len=le_uint32(size); header.data_chunk.len=le_uint32(size);
/* TODO: replace with "lseek" equivalent for windows */ /* TODO: replace with "lseek" equivalent for windows */
#if defined(_WIN32_WCE) fd=CreateFile(wUnicode, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
fd=CreateFile((LPCWSTR)filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
#else
fd=CreateFile(filename, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
#endif
if (fd==INVALID_HANDLE_VALUE){ if (fd==INVALID_HANDLE_VALUE){
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
ms_warning("Cannot open %s: %s",filename,strerror(errno)); ms_warning("Cannot open %s: %s",filename,strerror(errno));
...@@ -127,13 +128,12 @@ static int rec_open(MSFilter *f, void *arg){ ...@@ -127,13 +128,12 @@ static int rec_open(MSFilter *f, void *arg){
RecState *s=(RecState*)f->data; RecState *s=(RecState*)f->data;
const char *filename=(const char*)arg; const char *filename=(const char*)arg;
WCHAR wUnicode[1024];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, wUnicode, 1024);
ms_mutex_lock(&f->lock); ms_mutex_lock(&f->lock);
snprintf(s->filename, sizeof(s->filename), "%s", filename); snprintf(s->filename, sizeof(s->filename), "%s", filename);
#if defined(_WIN32_WCE) s->fd=CreateFile(wUnicode, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
s->fd=CreateFile((LPCWSTR)filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
#else
s->fd=CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
#endif
if (s->fd==INVALID_HANDLE_VALUE){ if (s->fd==INVALID_HANDLE_VALUE){
#if !defined(_WIN32_WCE) #if !defined(_WIN32_WCE)
ms_warning("Cannot open %s: %s",filename,strerror(errno)); ms_warning("Cannot open %s: %s",filename,strerror(errno));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment