]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia/mmfile.cpp
011726fc3ac018fb179b672bd1bcedd9cf7b284f
1 ////////////////////////////////////////////////////////////////////////////////
4 // Author: Guilhem Lavaux
7 // Copyright: (C) 1997, 1998, Guilhem Lavaux
8 // License: wxWindows license
9 ////////////////////////////////////////////////////////////////////////////////
11 #pragma implementation
18 #include <wx/stream.h>
19 #include <wx/wfstream.h>
20 #include <wx/mstream.h>
28 wxMMediaFile::wxMMediaFile()
29 : m_istream(NULL
), m_i_temp(NULL
), m_ostream(NULL
), m_o_temp(NULL
),
30 m_tmpfname((char *)NULL
), m_mfname((char *)NULL
),
35 wxMMediaFile::wxMMediaFile(wxOutputStream
& os
, bool seekable
)
36 : m_istream(NULL
), m_i_temp(NULL
), m_ostream(&os
), m_o_temp(NULL
),
37 m_tmpfname((char *)NULL
), m_mfname((char *)NULL
),
42 wxMMediaFile::wxMMediaFile(wxInputStream
& is
, bool preload
, bool seekable
)
43 : m_istream(&is
), m_i_temp(NULL
), m_ostream(NULL
), m_o_temp(NULL
),
44 m_tmpfname((char *)NULL
), m_mfname((char *)NULL
),
49 wxMemoryStream *tmpstream = new wxMemoryStream();
59 wxMMediaFile::wxMMediaFile(const wxString
& fname
)
60 : m_istream(NULL
), m_i_temp(NULL
), m_ostream(NULL
), m_o_temp(NULL
),
61 m_tmpfname((char *)NULL
), m_mfname(fname
),
64 wxFileStream
*s
= new wxFileStream(fname
);
71 void wxMMediaFile::SetFile(wxInputStream
& str
, bool preload
, bool seekable
)
76 m_seekable
= seekable
;
80 wxMemoryStream *tmpstream = new wxMemoryStream();
90 void wxMMediaFile::SetFile(wxOutputStream
& str
, bool seekable
)
95 m_seekable
= seekable
;
98 void wxMMediaFile::SetFile(const wxString
& fname
)
103 wxFileStream
*f
= new wxFileStream(fname
);
105 SetFile(*f
, FALSE
, TRUE
);
108 void wxMMediaFile::CleanUpPrevious()
114 m_ostream
->Write(*m_i_temp
);
116 delete m_i_temp
; // Only one delete because m_tmpo* and m_tmpi* are linked
119 wxRemoveFile(m_tmpfname
);
122 if (!m_mfname
.IsNull() && m_mfname
!= "")
131 wxMMediaFile::~wxMMediaFile()
136 wxMMtime
wxMMediaFile::GetLength()
138 wxMMtime mm_time
= {-1, 0, 0};
142 wxMMtime
wxMMediaFile::GetPosition()
144 wxMMtime mm_time
= {0, 0, 0};
148 wxInputStream
*wxMMediaFile::GetIRawData()
153 if (!m_seekable
&& !m_i_temp
)
156 return (m_i_temp
) ? m_i_temp
: m_istream
;
159 wxOutputStream
*wxMMediaFile::GetORawData()
164 if (!m_seekable
&& !m_i_temp
)
167 return (m_o_temp
) ? m_o_temp
: m_ostream
;
170 wxString
wxMMediaFile::GetCurrentFile()
172 if (!m_istream
&& !m_ostream
)
173 return wxString((char *)NULL
);
175 if (!m_mfname
&& !m_i_temp
)
178 return (!m_tmpfname
.IsEmpty()) ? m_tmpfname
: m_mfname
;
181 void wxMMediaFile::CacheIO()
183 if ((!m_istream
&& !m_ostream
) || m_i_temp
)
186 m_tmpfname
= wxGetTempFileName("mmd");
188 wxFileStream
*tmpstream
= new wxFileStream(m_tmpfname
);
189 m_i_temp
= tmpstream
;
190 m_o_temp
= tmpstream
;
193 tmpstream
->wxOutputStream::Write(*m_istream
);