summaryrefslogtreecommitdiffstats
path: root/dom/media/directshow/DirectShowUtils.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/media/directshow/DirectShowUtils.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/directshow/DirectShowUtils.h')
-rw-r--r--dom/media/directshow/DirectShowUtils.h125
1 files changed, 125 insertions, 0 deletions
diff --git a/dom/media/directshow/DirectShowUtils.h b/dom/media/directshow/DirectShowUtils.h
new file mode 100644
index 000000000..3bbc122fc
--- /dev/null
+++ b/dom/media/directshow/DirectShowUtils.h
@@ -0,0 +1,125 @@
+/* vim:set ts=2 sw=2 sts=2 et cindent: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef _DirectShowUtils_h_
+#define _DirectShowUtils_h_
+
+#include <stdint.h>
+#include "dshow.h"
+
+// XXXbz windowsx.h defines GetFirstChild, GetNextSibling,
+// GetPrevSibling are macros, apparently... Eeevil. We have functions
+// called that on some classes, so undef them.
+#undef GetFirstChild
+#undef GetNextSibling
+#undef GetPrevSibling
+
+#include "DShowTools.h"
+#include "mozilla/Logging.h"
+
+namespace mozilla {
+
+// Win32 "Event" wrapper. Must be paired with a CriticalSection to create a
+// Java-style "monitor".
+class Signal {
+public:
+
+ Signal(CriticalSection* aLock)
+ : mLock(aLock)
+ {
+ CriticalSectionAutoEnter lock(*mLock);
+ mEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+ }
+
+ ~Signal() {
+ CriticalSectionAutoEnter lock(*mLock);
+ CloseHandle(mEvent);
+ }
+
+ // Lock must be held.
+ void Notify() {
+ SetEvent(mEvent);
+ }
+
+ // Lock must be held. Check the wait condition before waiting!
+ HRESULT Wait() {
+ mLock->Leave();
+ DWORD result = WaitForSingleObject(mEvent, INFINITE);
+ mLock->Enter();
+ return result == WAIT_OBJECT_0 ? S_OK : E_FAIL;
+ }
+
+private:
+ CriticalSection* mLock;
+ HANDLE mEvent;
+};
+
+HRESULT
+AddGraphToRunningObjectTable(IUnknown *aUnkGraph, DWORD *aOutRotRegister);
+
+void
+RemoveGraphFromRunningObjectTable(DWORD aRotRegister);
+
+const char*
+GetGraphNotifyString(long evCode);
+
+// Creates a filter and adds it to a graph.
+HRESULT
+CreateAndAddFilter(IGraphBuilder* aGraph,
+ REFGUID aFilterClsId,
+ LPCWSTR aFilterName,
+ IBaseFilter **aOutFilter);
+
+HRESULT
+AddMP3DMOWrapperFilter(IGraphBuilder* aGraph,
+ IBaseFilter **aOutFilter);
+
+// Connects the output pin on aOutputFilter to an input pin on
+// aInputFilter, in aGraph.
+HRESULT
+ConnectFilters(IGraphBuilder* aGraph,
+ IBaseFilter* aOutputFilter,
+ IBaseFilter* aInputFilter);
+
+HRESULT
+MatchUnconnectedPin(IPin* aPin,
+ PIN_DIRECTION aPinDir,
+ bool *aOutMatches);
+
+// Converts from microseconds to DirectShow "Reference Time"
+// (hundreds of nanoseconds).
+inline int64_t
+UsecsToRefTime(const int64_t aUsecs)
+{
+ return aUsecs * 10;
+}
+
+// Converts from DirectShow "Reference Time" (hundreds of nanoseconds)
+// to microseconds.
+inline int64_t
+RefTimeToUsecs(const int64_t hRefTime)
+{
+ return hRefTime / 10;
+}
+
+// Converts from DirectShow "Reference Time" (hundreds of nanoseconds)
+// to seconds.
+inline double
+RefTimeToSeconds(const REFERENCE_TIME aRefTime)
+{
+ return double(aRefTime) / 10000000;
+}
+
+const char*
+GetDirectShowGuidName(const GUID& aGuid);
+
+// Returns true if we can instantiate an MP3 demuxer and decoder filters.
+// Use this to detect whether MP3 support is installed.
+bool
+CanDecodeMP3UsingDirectShow();
+
+} // namespace mozilla
+
+#endif