mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
添加c接口及测试程序
This commit is contained in:
parent
22448bf48a
commit
50f93cdc0b
1
c_wrapper/.idea/.name
Normal file
1
c_wrapper/.idea/.name
Normal file
@ -0,0 +1 @@
|
||||
MediaKitWrapper
|
2
c_wrapper/.idea/c_wrapper.iml
Normal file
2
c_wrapper/.idea/c_wrapper.iml
Normal file
@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
4
c_wrapper/.idea/misc.xml
Normal file
4
c_wrapper/.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
8
c_wrapper/.idea/modules.xml
Normal file
8
c_wrapper/.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/c_wrapper.iml" filepath="$PROJECT_DIR$/.idea/c_wrapper.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
524
c_wrapper/.idea/workspace.xml
Normal file
524
c_wrapper/.idea/workspace.xml
Normal file
@ -0,0 +1,524 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true" buildAllGenerated="true">
|
||||
<generated>
|
||||
<config projectName="MediaKitWrapper" targetName="MediaKitWrapper_static" />
|
||||
<config projectName="MediaKitWrapper" targetName="test_all" />
|
||||
<config projectName="MediaKitWrapper" targetName="MediaKitWrapper_shared" />
|
||||
</generated>
|
||||
</component>
|
||||
<component name="CMakeSettings" ADDITIONAL_BUILD_OPTIONS="-j4">
|
||||
<configurations>
|
||||
<configuration CONFIG_NAME="Debug" GENERATION_OPTIONS="-DOPENSSL_ROOT_DIR=/usr/local/Cellar/openssl/1.0.2j/" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="db5167c7-a7f4-4c11-a19e-0c6c8a7b66f1" name="Default" comment="" />
|
||||
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="httpdownloader.cpp" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/httpdownloader.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="242">
|
||||
<caret line="58" column="98" lean-forward="false" selection-start-line="58" selection-start-column="98" selection-end-line="58" selection-end-column="98" />
|
||||
<folding>
|
||||
<element signature="e#1238#1265#0" expanded="true" />
|
||||
<marker date="1513154719000" expanded="true" signature="0:1236" ph="/.../" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="media.cpp" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/media.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="142">
|
||||
<caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="proxyplayer.cpp" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/proxyplayer.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="24" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="common.cpp" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/common.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<caret line="82" column="18" lean-forward="false" selection-start-line="82" selection-start-column="18" selection-end-line="82" selection-end-column="18" />
|
||||
<folding>
|
||||
<element signature="e#1238#1257#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="media.h" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/media.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="473">
|
||||
<caret line="76" column="52" lean-forward="false" selection-start-line="76" selection-start-column="52" selection-end-line="76" selection-end-column="52" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="player.cpp" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/player.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="170">
|
||||
<caret line="179" column="45" lean-forward="false" selection-start-line="179" selection-start-column="25" selection-end-line="179" selection-end-column="45" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="PlayerBase.h" pinned="false" current-in-tab="false">
|
||||
<entry file="file:///usr/local/include/Player/PlayerBase.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="224">
|
||||
<caret line="187" column="9" lean-forward="false" selection-start-line="187" selection-start-column="9" selection-end-line="187" selection-end-column="9" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="player.h" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/player.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="347">
|
||||
<caret line="101" column="35" lean-forward="true" selection-start-line="101" selection-start-column="35" selection-end-line="101" selection-end-column="35" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="test_all.cpp" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/tests/test_all.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1213">
|
||||
<caret line="118" column="19" lean-forward="false" selection-start-line="118" selection-start-column="19" selection-end-line="118" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="e#1237#1258#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="common.h" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/common.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="163">
|
||||
<caret line="41" column="8" lean-forward="false" selection-start-line="41" selection-start-column="8" selection-end-line="41" selection-end-column="8" />
|
||||
<folding>
|
||||
<element signature="e#1324#1488#0" expanded="true" />
|
||||
<marker date="1513156321000" expanded="true" signature="3358:3361" ph="/.../" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>s_threadPool</find>
|
||||
</findStrings>
|
||||
</component>
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/tests/CMakeLists.txt" />
|
||||
<option value="$PROJECT_DIR$/CMakeLists.txt" />
|
||||
<option value="$PROJECT_DIR$/src/udpsearcher.h" />
|
||||
<option value="$PROJECT_DIR$/src/udpsearcher.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/media.h" />
|
||||
<option value="$PROJECT_DIR$/src/httpdownloader.h" />
|
||||
<option value="$PROJECT_DIR$/src/cleaner.h" />
|
||||
<option value="$PROJECT_DIR$/src/rtspApi.h" />
|
||||
<option value="$PROJECT_DIR$/src/httpdownloader.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/media.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/proxyplayer.h" />
|
||||
<option value="$PROJECT_DIR$/src/proxyplayer.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/common.h" />
|
||||
<option value="$PROJECT_DIR$/src/common.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/mediakit.h" />
|
||||
<option value="$PROJECT_DIR$/tests/test_all.cpp.cpp" />
|
||||
<option value="$PROJECT_DIR$/src/player.h" />
|
||||
<option value="$PROJECT_DIR$/src/player.cpp" />
|
||||
<option value="$PROJECT_DIR$/tests/test_all.cpp" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsGulpfileManager">
|
||||
<detection-done>true</detection-done>
|
||||
<sorting>DEFINITION_ORDER</sorting>
|
||||
</component>
|
||||
<component name="OCFindUsagesOptions" text="true" ivars="false" properties="true" derivedClasses="false" />
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="y" value="23" />
|
||||
<option name="width" value="1280" />
|
||||
<option name="height" value="1057" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
<showLibraryContents />
|
||||
<hideEmptyPackages />
|
||||
<abbreviatePackageNames />
|
||||
<autoscrollToSource />
|
||||
<autoscrollFromSource />
|
||||
<sortByType />
|
||||
<manualOrder />
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="MediaKitWrapper" type="dad4c3:CidrFilesViewHelper$MyProjectTreeStructure$1" />
|
||||
<item name="c_wrapper" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="MediaKitWrapper" type="dad4c3:CidrFilesViewHelper$MyProjectTreeStructure$1" />
|
||||
<item name="c_wrapper" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="MediaKitWrapper" type="dad4c3:CidrFilesViewHelper$MyProjectTreeStructure$1" />
|
||||
<item name="c_wrapper" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="tests" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/CMakeLists.txt" />
|
||||
<property name="settings.editor.selected.configurable" value="CMakeSettings" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/cmake" />
|
||||
<recent name="$PROJECT_DIR$/tests" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager" selected="Application.test_all">
|
||||
<configuration name="Build All" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" CONFIG_NAME="Debug" EXPLICIT_BUILD_TARGET_NAME="all">
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration name="MediaKitWrapper_shared" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="MediaKitWrapper" TARGET_NAME="MediaKitWrapper_shared" CONFIG_NAME="Debug">
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration name="MediaKitWrapper_static" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="MediaKitWrapper" TARGET_NAME="MediaKitWrapper_static" CONFIG_NAME="Debug">
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration name="test_all" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="MediaKitWrapper" TARGET_NAME="test_all" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="MediaKitWrapper" RUN_TARGET_NAME="test_all">
|
||||
<envs />
|
||||
</configuration>
|
||||
<list size="4">
|
||||
<item index="0" class="java.lang.String" itemvalue="Application.Build All" />
|
||||
<item index="1" class="java.lang.String" itemvalue="Application.MediaKitWrapper_shared" />
|
||||
<item index="2" class="java.lang.String" itemvalue="Application.MediaKitWrapper_static" />
|
||||
<item index="3" class="java.lang.String" itemvalue="Application.test_all" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ShelveChangesManager" show_recycled="false">
|
||||
<option name="remove_strategy" value="false" />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="db5167c7-a7f4-4c11-a19e-0c6c8a7b66f1" name="Default" comment="" />
|
||||
<created>1513153608354</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1513153608354</updated>
|
||||
<workItem from="1513153610227" duration="5193000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="5193000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="0" y="23" width="1852" height="1057" extended-state="6" />
|
||||
<layout>
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.19779006" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32952183" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="CMake" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3846154" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.44282743" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3991684" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
|
||||
<url>file://$PROJECT_DIR$/tests/test_all.cpp</url>
|
||||
<line>67</line>
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
|
||||
<url>file://$PROJECT_DIR$/tests/test_all.cpp</url>
|
||||
<line>88</line>
|
||||
<option name="timeStamp" value="1" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
|
||||
<url>file://$PROJECT_DIR$/tests/test_all.cpp</url>
|
||||
<line>99</line>
|
||||
<option name="timeStamp" value="2" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
|
||||
<url>file://$PROJECT_DIR$/tests/test_all.cpp</url>
|
||||
<line>110</line>
|
||||
<option name="timeStamp" value="3" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
<option name="time" value="4" />
|
||||
</breakpoint-manager>
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/cmake/FindFAAC.cmake">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="114">
|
||||
<caret line="6" column="25" lean-forward="false" selection-start-line="6" selection-start-column="25" selection-end-line="6" selection-end-column="25" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/proxy.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-2051">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/udpsearcher.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="456">
|
||||
<caret line="24" column="3" lean-forward="false" selection-start-line="24" selection-start-column="3" selection-end-line="24" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/udpsearcher.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="206">
|
||||
<caret line="33" column="9" lean-forward="false" selection-start-line="33" selection-start-column="9" selection-end-line="33" selection-end-column="9" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="19">
|
||||
<caret line="1" column="23" lean-forward="false" selection-start-line="1" selection-start-column="8" selection-end-line="1" selection-end-column="23" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/cleaner.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="206">
|
||||
<caret line="49" column="16" lean-forward="false" selection-start-line="49" selection-start-column="16" selection-end-line="49" selection-end-column="16" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file:///usr/local/include/Player/MediaPlayer.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="206">
|
||||
<caret line="43" column="6" lean-forward="false" selection-start-line="43" selection-start-column="6" selection-end-line="43" selection-end-column="6" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file:///usr/local/include/Device/PlayerProxy.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="206">
|
||||
<caret line="49" column="11" lean-forward="false" selection-start-line="49" selection-start-column="11" selection-end-line="49" selection-end-column="11" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/mediakit.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="449">
|
||||
<caret line="33" column="0" lean-forward="false" selection-start-line="33" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/tests/CMakeLists.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="266">
|
||||
<caret line="14" column="37" lean-forward="false" selection-start-line="14" selection-start-column="37" selection-end-line="14" selection-end-column="37" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/proxyplayer.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="367">
|
||||
<caret line="44" column="29" lean-forward="false" selection-start-line="44" selection-start-column="11" selection-end-line="44" selection-end-column="29" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/httpdownloader.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="343">
|
||||
<caret line="37" column="107" lean-forward="true" selection-start-line="37" selection-start-column="44" selection-end-line="37" selection-end-column="107" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/common.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="163">
|
||||
<caret line="41" column="8" lean-forward="false" selection-start-line="41" selection-start-column="8" selection-end-line="41" selection-end-column="8" />
|
||||
<folding>
|
||||
<element signature="e#1324#1488#0" expanded="true" />
|
||||
<marker date="1513156321000" expanded="true" signature="3358:3361" ph="/.../" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file:///usr/local/include/Player/PlayerBase.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="224">
|
||||
<caret line="187" column="9" lean-forward="false" selection-start-line="187" selection-start-column="9" selection-end-line="187" selection-end-column="9" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/media.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="473">
|
||||
<caret line="76" column="52" lean-forward="false" selection-start-line="76" selection-start-column="52" selection-end-line="76" selection-end-column="52" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/proxyplayer.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="24" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/common.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="240">
|
||||
<caret line="82" column="18" lean-forward="false" selection-start-line="82" selection-start-column="18" selection-end-line="82" selection-end-column="18" />
|
||||
<folding>
|
||||
<element signature="e#1238#1257#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/httpdownloader.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="242">
|
||||
<caret line="58" column="98" lean-forward="false" selection-start-line="58" selection-start-column="98" selection-end-line="58" selection-end-column="98" />
|
||||
<folding>
|
||||
<element signature="e#1238#1265#0" expanded="true" />
|
||||
<marker date="1513154719000" expanded="true" signature="0:1236" ph="/.../" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/media.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="142">
|
||||
<caret line="71" column="0" lean-forward="false" selection-start-line="71" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/player.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="347">
|
||||
<caret line="101" column="35" lean-forward="true" selection-start-line="101" selection-start-column="35" selection-end-line="101" selection-end-column="35" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/player.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="170">
|
||||
<caret line="179" column="45" lean-forward="false" selection-start-line="179" selection-start-column="25" selection-end-line="179" selection-end-column="45" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/tests/test_all.cpp">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1213">
|
||||
<caret line="118" column="19" lean-forward="false" selection-start-line="118" selection-start-column="19" selection-end-line="118" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="e#1237#1258#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
126
c_wrapper/CMakeLists.txt
Executable file
126
c_wrapper/CMakeLists.txt
Executable file
@ -0,0 +1,126 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(MediaKitWrapper)
|
||||
|
||||
#加载自定义模块
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||
#设置库文件路径
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
#设置可执行程序路径
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
|
||||
#设置需要链接的库
|
||||
set(LINK_LIB_LIST)
|
||||
|
||||
#安装目录
|
||||
if(WIN32)
|
||||
set(INSTALL_PATH_LIB $ENV{HOME}/${CMAKE_PROJECT_NAME}/lib)
|
||||
set(INSTALL_PATH_INCLUDE $ENV{HOME}/${CMAKE_PROJECT_NAME}/include)
|
||||
else()
|
||||
set(INSTALL_PATH_LIB lib)
|
||||
set(INSTALL_PATH_INCLUDE include)
|
||||
endif()
|
||||
|
||||
#查找openssl是否安装
|
||||
find_package(OpenSSL QUIET)
|
||||
if(OPENSSL_FOUND)
|
||||
message(STATUS "找到openssl库:\"${OPENSSL_INCLUDE_DIR}\",ENABLE_OPENSSL宏已打开")
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
add_definitions(-DENABLE_OPENSSL)
|
||||
list(APPEND LINK_LIB_LIST ${OPENSSL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
#查找mysql是否安装
|
||||
find_package(MYSQL QUIET)
|
||||
if(MYSQL_FOUND)
|
||||
message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
|
||||
include_directories(${MYSQL_INCLUDE_DIR})
|
||||
add_definitions(-DENABLE_MYSQL)
|
||||
list(APPEND LINK_LIB_LIST ${MYSQL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
#查找mp4v2是否安装
|
||||
find_package(MP4V2 QUIET)
|
||||
if(MP4V2_FOUND)
|
||||
message(STATUS "找到mp4v2库:\"${MP4V2_INCLUDE_DIR}\",ENABLE_MP4V2宏已打开")
|
||||
include_directories(${MP4V2_INCLUDE_DIR})
|
||||
add_definitions(-DENABLE_MP4V2)
|
||||
list(APPEND LINK_LIB_LIST ${MP4V2_LIBRARIES})
|
||||
endif()
|
||||
|
||||
#查找x264是否安装
|
||||
find_package(X264 QUIET)
|
||||
if(X264_FOUND)
|
||||
message(STATUS "找到x264库:\"${X264_INCLUDE_DIRS}\",ENABLE_X264宏已打开")
|
||||
include_directories(${X264_INCLUDE_DIRS})
|
||||
add_definitions(-DENABLE_X264)
|
||||
list(APPEND LINK_LIB_LIST ${X264_LIBRARIES})
|
||||
endif()
|
||||
|
||||
#查找faac是否安装
|
||||
find_package(FAAC QUIET)
|
||||
if(FAAC_FOUND)
|
||||
message(STATUS "找到faac库:\"${FAAC_INCLUDE_DIR}\",ENABLE_FAAC宏已打开")
|
||||
include_directories(${FAAC_INCLUDE_DIR})
|
||||
add_definitions(-DENABLE_FAAC)
|
||||
list(APPEND LINK_LIB_LIST ${FAAC_LIBRARIES})
|
||||
endif()
|
||||
|
||||
#查找ZLToolKit是否安装
|
||||
find_package(ZLTOOLKIT QUIET)
|
||||
if(ZLTOOLKIT_FOUND)
|
||||
message(STATUS "找到ZLToolKit库:\"${ZLTOOLKIT_INCLUDE_DIR}\"")
|
||||
include_directories(${ZLTOOLKIT_INCLUDE_DIR})
|
||||
list(APPEND LINK_LIB_LIST ${ZLTOOLKIT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
#查找ZLMediaKit是否安装
|
||||
find_package(ZLMEDIAKIT QUIET)
|
||||
if(ZLMEDIAKIT_FOUND)
|
||||
message(STATUS "找到ZLMediaKit库:\"${ZLMEDIAKIT_INCLUDE_DIR}\"")
|
||||
include_directories(${ZLMEDIAKIT_INCLUDE_DIR})
|
||||
list(APPEND LINK_LIB_LIST ${ZLMEDIAKIT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
#打印库文件
|
||||
message(STATUS "将链接依赖库:${LINK_LIB_LIST}")
|
||||
#开启RTSP/RTMP之间的互相转换,开启HLS
|
||||
add_definitions(-DENABLE_RTMP2RTSP -DENABLE_RTSP2RTMP -DENABLE_HLS -DHAVE_CONFIG_H)
|
||||
|
||||
#引用头文件路径
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
#使能c++11
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if(NOT WIN32)
|
||||
#关闭过期接口警告
|
||||
add_compile_options(-Wno-deprecated-declarations)
|
||||
#关闭__FUNCTION__宏在函数外警告
|
||||
add_compile_options(-Wno-predefined-identifier-outside-function)
|
||||
endif(NOT WIN32)
|
||||
|
||||
#收集源文件
|
||||
file(GLOB SRC_LIST src/*.cpp src/*.h)
|
||||
|
||||
#编译动态库
|
||||
if(NOT IOS AND NOT ANDROID)
|
||||
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
|
||||
set_target_properties(${CMAKE_PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
||||
install(TARGETS ${CMAKE_PROJECT_NAME}_shared ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB})
|
||||
if(WIN32)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST} WS2_32 Iphlpapi shlwapi)
|
||||
else(WIN32)
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST})
|
||||
endif(WIN32)
|
||||
endif()
|
||||
|
||||
#编译静态库
|
||||
add_library(${CMAKE_PROJECT_NAME}_static STATIC ${SRC_LIST})
|
||||
set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
||||
install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION ${INSTALL_PATH_LIB})
|
||||
|
||||
#测试程序
|
||||
if(NOT IOS)
|
||||
add_subdirectory(tests)
|
||||
endif(NOT IOS)
|
96
c_wrapper/cmake/AndroidNdkGdb.cmake
Executable file
96
c_wrapper/cmake/AndroidNdkGdb.cmake
Executable file
@ -0,0 +1,96 @@
|
||||
# Copyright (c) 2014, Pavel Rojtberg
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Usage:
|
||||
# 1. place AndroidNdkGdb.cmake somewhere inside ${CMAKE_MODULE_PATH}
|
||||
# 2. inside your project add
|
||||
#
|
||||
# include(AndroidNdkGdb)
|
||||
# android_ndk_gdb_enable()
|
||||
# # for each target
|
||||
# add_library(MyLibrary ...)
|
||||
# android_ndk_gdb_debuggable(MyLibrary)
|
||||
|
||||
|
||||
# add gdbserver and general gdb configuration to project
|
||||
# also create a mininal NDK skeleton so ndk-gdb finds the paths
|
||||
#
|
||||
# the optional parameter defines the path to the android project.
|
||||
# uses PROJECT_SOURCE_DIR by default.
|
||||
macro(android_ndk_gdb_enable)
|
||||
if(ANDROID)
|
||||
# create custom target that depends on the real target so it gets executed afterwards
|
||||
add_custom_target(NDK_GDB ALL)
|
||||
|
||||
if(${ARGC})
|
||||
set(ANDROID_PROJECT_DIR ${ARGV0})
|
||||
else()
|
||||
set(ANDROID_PROJECT_DIR ${PROJECT_SOURCE_DIR})
|
||||
endif()
|
||||
|
||||
set(NDK_GDB_SOLIB_PATH ${ANDROID_PROJECT_DIR}/obj/local/${ANDROID_NDK_ABI_NAME}/)
|
||||
file(MAKE_DIRECTORY ${NDK_GDB_SOLIB_PATH})
|
||||
|
||||
# 1. generate essential Android Makefiles
|
||||
file(MAKE_DIRECTORY ${ANDROID_PROJECT_DIR}/jni)
|
||||
if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Android.mk)
|
||||
file(WRITE ${ANDROID_PROJECT_DIR}/jni/Android.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
|
||||
endif()
|
||||
if(NOT EXISTS ${ANDROID_PROJECT_DIR}/jni/Application.mk)
|
||||
file(WRITE ${ANDROID_PROJECT_DIR}/jni/Application.mk "APP_ABI := ${ANDROID_NDK_ABI_NAME}\n")
|
||||
endif()
|
||||
|
||||
# 2. generate gdb.setup
|
||||
get_directory_property(PROJECT_INCLUDES DIRECTORY ${PROJECT_SOURCE_DIR} INCLUDE_DIRECTORIES)
|
||||
string(REGEX REPLACE ";" " " PROJECT_INCLUDES "${PROJECT_INCLUDES}")
|
||||
file(WRITE ${LIBRARY_OUTPUT_PATH}/gdb.setup "set solib-search-path ${NDK_GDB_SOLIB_PATH}\n")
|
||||
file(APPEND ${LIBRARY_OUTPUT_PATH}/gdb.setup "directory ${PROJECT_INCLUDES}\n")
|
||||
|
||||
# 3. copy gdbserver executable
|
||||
file(COPY ${ANDROID_NDK}/prebuilt/android-${ANDROID_ARCH_NAME}/gdbserver/gdbserver DESTINATION ${LIBRARY_OUTPUT_PATH})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# register a target for remote debugging
|
||||
# copies the debug version to NDK_GDB_SOLIB_PATH then strips symbols of original
|
||||
macro(android_ndk_gdb_debuggable TARGET_NAME)
|
||||
if(ANDROID)
|
||||
get_property(TARGET_LOCATION TARGET ${TARGET_NAME} PROPERTY LOCATION)
|
||||
|
||||
# create custom target that depends on the real target so it gets executed afterwards
|
||||
add_dependencies(NDK_GDB ${TARGET_NAME})
|
||||
|
||||
# 4. copy lib to obj
|
||||
add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${TARGET_LOCATION} ${NDK_GDB_SOLIB_PATH})
|
||||
|
||||
# 5. strip symbols
|
||||
add_custom_command(TARGET NDK_GDB POST_BUILD COMMAND ${CMAKE_STRIP} ${TARGET_LOCATION})
|
||||
endif()
|
||||
endmacro()
|
58
c_wrapper/cmake/AndroidNdkModules.cmake
Executable file
58
c_wrapper/cmake/AndroidNdkModules.cmake
Executable file
@ -0,0 +1,58 @@
|
||||
# Copyright (c) 2014, Pavel Rojtberg
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its
|
||||
# contributors may be used to endorse or promote products derived from this
|
||||
# software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
macro(android_ndk_import_module_cpufeatures)
|
||||
if(ANDROID)
|
||||
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
|
||||
add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
|
||||
target_link_libraries(cpufeatures dl)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(android_ndk_import_module_native_app_glue)
|
||||
if(ANDROID)
|
||||
include_directories(${ANDROID_NDK}/sources/android/native_app_glue)
|
||||
add_library(native_app_glue ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
||||
target_link_libraries(native_app_glue log)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(android_ndk_import_module_ndk_helper)
|
||||
if(ANDROID)
|
||||
android_ndk_import_module_cpufeatures()
|
||||
android_ndk_import_module_native_app_glue()
|
||||
|
||||
include_directories(${ANDROID_NDK}/sources/android/ndk_helper)
|
||||
file(GLOB _NDK_HELPER_SRCS ${ANDROID_NDK}/sources/android/ndk_helper/*.cpp ${ANDROID_NDK}/sources/android/ndk_helper/gl3stub.c)
|
||||
add_library(ndk_helper ${_NDK_HELPER_SRCS})
|
||||
target_link_libraries(ndk_helper log android EGL GLESv2 cpufeatures native_app_glue)
|
||||
|
||||
unset(_NDK_HELPER_SRCS)
|
||||
endif()
|
||||
endmacro()
|
14
c_wrapper/cmake/FindAVCODEC.cmake
Executable file
14
c_wrapper/cmake/FindAVCODEC.cmake
Executable file
@ -0,0 +1,14 @@
|
||||
find_path(AVCODEC_INCLUDE_DIR
|
||||
NAMES libavcodec/avcodec.h
|
||||
PATHS $ENV{HOME}/ffmpeg/include)
|
||||
|
||||
find_library(AVCODEC_LIBRARY
|
||||
NAMES avcodec
|
||||
PATHS $ENV{HOME}/ffmpeg/lib)
|
||||
|
||||
set(AVCODEC_LIBRARIES ${AVCODEC_LIBRARY})
|
||||
set(AVCODEC_INCLUDE_DIRS ${AVCODEC_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(AVCODEC DEFAULT_MSG AVCODEC_LIBRARY AVCODEC_INCLUDE_DIR)
|
14
c_wrapper/cmake/FindAVUTIL.cmake
Executable file
14
c_wrapper/cmake/FindAVUTIL.cmake
Executable file
@ -0,0 +1,14 @@
|
||||
find_path(AVUTIL_INCLUDE_DIR
|
||||
NAMES libavutil/avutil.h
|
||||
PATHS $ENV{HOME}/ffmpeg/include)
|
||||
|
||||
find_library(AVUTIL_LIBRARY
|
||||
NAMES avutil
|
||||
PATHS $ENV{HOME}/ffmpeg/lib)
|
||||
|
||||
set(AVUTIL_LIBRARIES ${AVUTIL_LIBRARY})
|
||||
set(AVUTIL_INCLUDE_DIRS ${AVUTIL_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(AVUTIL DEFAULT_MSG AVUTIL_LIBRARY AVUTIL_INCLUDE_DIR)
|
16
c_wrapper/cmake/FindFAAC.cmake
Normal file
16
c_wrapper/cmake/FindFAAC.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
find_path(FAAC_INCLUDE_DIR
|
||||
NAMES faac.h
|
||||
)
|
||||
|
||||
find_library(FAAC_LIBRARY
|
||||
NAMES faac
|
||||
)
|
||||
|
||||
set(FAAC_INCLUDE_DIRS ${FAAC_INCLUDE_DIR})
|
||||
set(FAAC_LIBRARIES ${FAAC_LIBRARY})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(FAAC DEFAULT_MSG FAAC_LIBRARY FAAC_INCLUDE_DIR)
|
14
c_wrapper/cmake/FindMP4V2.cmake
Normal file
14
c_wrapper/cmake/FindMP4V2.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
find_path(MP4V2_INCLUDE_DIR
|
||||
NAMES mp4v2/mp4v2.h)
|
||||
|
||||
find_library(MP4V2_LIBRARY
|
||||
NAMES mp4v2)
|
||||
|
||||
set(MP4V2_LIBRARIES ${MP4V2_LIBRARY})
|
||||
set(MP4V2_INCLUDE_DIRS ${MP4V2_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set MP4V2_FOUND to TRUE
|
||||
# if all listed variables are TRUE
|
||||
find_package_handle_standard_args(MP4V2 DEFAULT_MSG MP4V2_LIBRARY MP4V2_INCLUDE_DIR)
|
130
c_wrapper/cmake/FindMYSQL.cmake
Executable file
130
c_wrapper/cmake/FindMYSQL.cmake
Executable file
@ -0,0 +1,130 @@
|
||||
# - Try to find MySQL / MySQL Embedded library
|
||||
# Find the MySQL includes and client library
|
||||
# This module defines
|
||||
# MYSQL_INCLUDE_DIR, where to find mysql.h
|
||||
# MYSQL_LIBRARIES, the libraries needed to use MySQL.
|
||||
# MYSQL_LIB_DIR, path to the MYSQL_LIBRARIES
|
||||
# MYSQL_EMBEDDED_LIBRARIES, the libraries needed to use MySQL Embedded.
|
||||
# MYSQL_EMBEDDED_LIB_DIR, path to the MYSQL_EMBEDDED_LIBRARIES
|
||||
# MYSQL_FOUND, If false, do not try to use MySQL.
|
||||
# MYSQL_EMBEDDED_FOUND, If false, do not try to use MySQL Embedded.
|
||||
|
||||
# Copyright (c) 2006-2008, Jarosław Staniek <staniek@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
if(WIN32)
|
||||
find_path(MYSQL_INCLUDE_DIR mysql.h
|
||||
PATHS
|
||||
$ENV{MYSQL_INCLUDE_DIR}
|
||||
$ENV{MYSQL_DIR}/include
|
||||
$ENV{ProgramFiles}/MySQL/*/include
|
||||
$ENV{SystemDrive}/MySQL/*/include
|
||||
$ENV{ProgramW6432}/MySQL/*/include
|
||||
)
|
||||
else(WIN32)
|
||||
find_path(MYSQL_INCLUDE_DIR mysql/mysql.h
|
||||
PATHS
|
||||
$ENV{MYSQL_INCLUDE_DIR}
|
||||
$ENV{MYSQL_DIR}/include
|
||||
/usr/local/mysql/include
|
||||
/opt/mysql/mysql/include
|
||||
PATH_SUFFIXES
|
||||
mysql
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
if(WIN32)
|
||||
if (${CMAKE_BUILD_TYPE})
|
||||
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
|
||||
endif()
|
||||
|
||||
# path suffix for debug/release mode
|
||||
# binary_dist: mysql binary distribution
|
||||
# build_dist: custom build
|
||||
if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
|
||||
set(binary_dist debug)
|
||||
set(build_dist Debug)
|
||||
else(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
|
||||
ADD_DEFINITIONS(-DDBUG_OFF)
|
||||
set(binary_dist opt)
|
||||
set(build_dist Release)
|
||||
endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug")
|
||||
|
||||
# find_library(MYSQL_LIBRARIES NAMES mysqlclient
|
||||
set(MYSQL_LIB_PATHS
|
||||
$ENV{MYSQL_DIR}/lib/${binary_dist}
|
||||
$ENV{MYSQL_DIR}/libmysql/${build_dist}
|
||||
$ENV{MYSQL_DIR}/client/${build_dist}
|
||||
$ENV{ProgramFiles}/MySQL/*/lib/${binary_dist}
|
||||
$ENV{SystemDrive}/MySQL/*/lib/${binary_dist}
|
||||
$ENV{MYSQL_DIR}/lib/opt
|
||||
$ENV{MYSQL_DIR}/client/release
|
||||
$ENV{ProgramFiles}/MySQL/*/lib/opt
|
||||
$ENV{ProgramFiles}/MySQL/*/lib/
|
||||
$ENV{SystemDrive}/MySQL/*/lib/opt
|
||||
$ENV{ProgramW6432}/MySQL/*/lib
|
||||
)
|
||||
find_library(MYSQL_LIBRARIES NAMES libmysql
|
||||
PATHS
|
||||
${MYSQL_LIB_PATHS}
|
||||
)
|
||||
else(WIN32)
|
||||
# find_library(MYSQL_LIBRARIES NAMES mysqlclient
|
||||
set(MYSQL_LIB_PATHS
|
||||
$ENV{MYSQL_DIR}/libmysql_r/.libs
|
||||
$ENV{MYSQL_DIR}/lib
|
||||
$ENV{MYSQL_DIR}/lib/mysql
|
||||
/usr/local/mysql/lib
|
||||
/opt/mysql/mysql/lib
|
||||
$ENV{MYSQL_DIR}/libmysql_r/.libs
|
||||
$ENV{MYSQL_DIR}/lib
|
||||
$ENV{MYSQL_DIR}/lib/mysql
|
||||
/usr/local/mysql/lib
|
||||
/opt/mysql/mysql/lib
|
||||
PATH_SUFFIXES
|
||||
mysql
|
||||
)
|
||||
find_library(MYSQL_LIBRARIES NAMES mysqlclient
|
||||
PATHS
|
||||
${MYSQL_LIB_PATHS}
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
find_library(MYSQL_EMBEDDED_LIBRARIES NAMES mysqld
|
||||
PATHS
|
||||
${MYSQL_LIB_PATHS}
|
||||
)
|
||||
|
||||
if(MYSQL_LIBRARIES)
|
||||
get_filename_component(MYSQL_LIB_DIR ${MYSQL_LIBRARIES} PATH)
|
||||
endif(MYSQL_LIBRARIES)
|
||||
|
||||
if(MYSQL_EMBEDDED_LIBRARIES)
|
||||
get_filename_component(MYSQL_EMBEDDED_LIB_DIR ${MYSQL_EMBEDDED_LIBRARIES} PATH)
|
||||
endif(MYSQL_EMBEDDED_LIBRARIES)
|
||||
|
||||
set( CMAKE_REQUIRED_INCLUDES ${MYSQL_INCLUDE_DIR} )
|
||||
set( CMAKE_REQUIRED_LIBRARIES ${MYSQL_EMBEDDED_LIBRARIES} )
|
||||
check_cxx_source_compiles( "#include <mysql.h>\nint main() { int i = MYSQL_OPT_USE_EMBEDDED_CONNECTION; }" HAVE_MYSQL_OPT_EMBEDDED_CONNECTION )
|
||||
|
||||
if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
|
||||
set(MYSQL_FOUND TRUE)
|
||||
message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARIES}")
|
||||
else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
|
||||
set(MYSQL_FOUND FALSE)
|
||||
message(STATUS "MySQL not found.")
|
||||
endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
|
||||
|
||||
if(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
|
||||
set(MYSQL_EMBEDDED_FOUND TRUE)
|
||||
message(STATUS "Found MySQL Embedded: ${MYSQL_INCLUDE_DIR}, ${MYSQL_EMBEDDED_LIBRARIES}")
|
||||
else(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
|
||||
set(MYSQL_EMBEDDED_FOUND FALSE)
|
||||
message(STATUS "MySQL Embedded not found.")
|
||||
endif(MYSQL_INCLUDE_DIR AND MYSQL_EMBEDDED_LIBRARIES AND HAVE_MYSQL_OPT_EMBEDDED_CONNECTION)
|
||||
|
||||
mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES MYSQL_EMBEDDED_LIBRARIES)
|
15
c_wrapper/cmake/FindSDL2.cmake
Executable file
15
c_wrapper/cmake/FindSDL2.cmake
Executable file
@ -0,0 +1,15 @@
|
||||
find_path(SDL2_INCLUDE_DIR
|
||||
NAMES SDL2/SDL.h
|
||||
HINTS SDL2
|
||||
PATHS $ENV{HOME}/sdl2/include)
|
||||
|
||||
find_library(SDL2_LIBRARY
|
||||
NAMES SDL2
|
||||
PATHS $ENV{HOME}/sdl2/lib/x86)
|
||||
|
||||
set(SDL2_LIBRARIES ${SDL2_LIBRARY})
|
||||
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SDL2 DEFAULT_MSG SDL2_LIBRARY SDL2_INCLUDE_DIR)
|
57
c_wrapper/cmake/FindX264.cmake
Normal file
57
c_wrapper/cmake/FindX264.cmake
Normal file
@ -0,0 +1,57 @@
|
||||
############################################################################
|
||||
# FindX264.txt
|
||||
# Copyright (C) 2015 Belledonne Communications, Grenoble France
|
||||
#
|
||||
############################################################################
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
############################################################################
|
||||
#
|
||||
# - Find the x264 include file and library
|
||||
#
|
||||
# X264_FOUND - system has x264
|
||||
# X264_INCLUDE_DIRS - the x264 include directory
|
||||
# X264_LIBRARIES - The libraries needed to use x264
|
||||
|
||||
include(CMakePushCheckState)
|
||||
include(CheckCXXSymbolExists)
|
||||
|
||||
set(_X264_ROOT_PATHS
|
||||
${CMAKE_INSTALL_PREFIX}
|
||||
)
|
||||
|
||||
find_path(X264_INCLUDE_DIRS
|
||||
NAMES x264.h
|
||||
HINTS _X264_ROOT_PATHS
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
if(X264_INCLUDE_DIRS)
|
||||
set(HAVE_X264_H 1)
|
||||
endif()
|
||||
|
||||
find_library(X264_LIBRARIES
|
||||
NAMES x264
|
||||
HINTS _X264_ROOT_PATHS
|
||||
PATH_SUFFIXES bin lib
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(X264
|
||||
DEFAULT_MSG
|
||||
X264_INCLUDE_DIRS X264_LIBRARIES HAVE_X264_H
|
||||
)
|
||||
|
||||
mark_as_advanced(X264_INCLUDE_DIRS X264_LIBRARIES HAVE_X264_H)
|
19
c_wrapper/cmake/FindZLMEDIAKIT.cmake
Executable file
19
c_wrapper/cmake/FindZLMEDIAKIT.cmake
Executable file
@ -0,0 +1,19 @@
|
||||
find_path(ZLMEDIAKIT_INCLUDE_DIR
|
||||
NAMES Rtsp/Rtsp.h
|
||||
PATHS
|
||||
${PROJECT_SOURCE_DIR}/../ZLMediaKit/src
|
||||
$ENV{HOME}/ZLMediaKit/include)
|
||||
|
||||
find_library(ZLMEDIAKIT_LIBRARY
|
||||
NAMES ZLMediaKit
|
||||
PATHS
|
||||
${PROJECT_SOURCE_DIR}/../ZLMediaKit/build/lib
|
||||
$ENV{HOME}/ZLMediaKit/lib)
|
||||
|
||||
set(ZLMEDIAKIT_LIBRARIES ${ZLMEDIAKIT_LIBRARY})
|
||||
set(ZLMEDIAKIT_INCLUDE_DIRS ${ZLMEDIAKIT_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(ZLMEDIAKIT DEFAULT_MSG ZLMEDIAKIT_LIBRARY ZLMEDIAKIT_INCLUDE_DIR)
|
||||
|
18
c_wrapper/cmake/FindZLTOOLKIT.cmake
Executable file
18
c_wrapper/cmake/FindZLTOOLKIT.cmake
Executable file
@ -0,0 +1,18 @@
|
||||
find_path(ZLTOOLKIT_INCLUDE_DIR
|
||||
NAMES Network/Socket.h
|
||||
PATHS
|
||||
${PROJECT_SOURCE_DIR}/../ZLToolKit/src
|
||||
$ENV{HOME}/ZLToolKit/include)
|
||||
|
||||
find_library(ZLTOOLKIT_LIBRARY
|
||||
NAMES ZLToolKit
|
||||
PATHS
|
||||
${PROJECT_SOURCE_DIR}/../ZLToolKit/build/lib
|
||||
$ENV{HOME}/ZLToolKit/lib)
|
||||
|
||||
set(ZLTOOLKIT_LIBRARIES ${ZLTOOLKIT_LIBRARY})
|
||||
set(ZLTOOLKIT_INCLUDE_DIRS ${ZLTOOLKIT_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(ZLTOOLKIT DEFAULT_MSG ZLTOOLKIT_LIBRARY ZLTOOLKIT_INCLUDE_DIR)
|
1693
c_wrapper/cmake/android.toolchain.cmake
Executable file
1693
c_wrapper/cmake/android.toolchain.cmake
Executable file
File diff suppressed because it is too large
Load Diff
209
c_wrapper/cmake/iOS.cmake
Executable file
209
c_wrapper/cmake/iOS.cmake
Executable file
@ -0,0 +1,209 @@
|
||||
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
|
||||
# files which are included with CMake 2.8.4
|
||||
# It has been altered for iOS development
|
||||
|
||||
# Options:
|
||||
#
|
||||
# IOS_PLATFORM = OS (default) or SIMULATOR or SIMULATOR64
|
||||
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
|
||||
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
|
||||
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
|
||||
#
|
||||
# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
|
||||
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
|
||||
# If set manually, it will override the default location and force the user of a particular Developer Platform
|
||||
#
|
||||
# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
|
||||
# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
|
||||
# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
|
||||
# If set manually, this will force the use of a specific SDK version
|
||||
|
||||
# Macros:
|
||||
#
|
||||
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE)
|
||||
# A convenience macro for setting xcode specific properties on targets
|
||||
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1")
|
||||
#
|
||||
# find_host_package (PROGRAM ARGS)
|
||||
# A macro used to find executable programs on the host system, not within the iOS environment.
|
||||
# Thanks to the android-cmake project for providing the command
|
||||
|
||||
# Standard settings
|
||||
set (CMAKE_SYSTEM_NAME Darwin)
|
||||
set (CMAKE_SYSTEM_VERSION 1)
|
||||
set (UNIX True)
|
||||
set (APPLE True)
|
||||
set (IOS True)
|
||||
|
||||
# Required as of cmake 2.8.10
|
||||
set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
|
||||
|
||||
# Determine the cmake host system version so we know where to find the iOS SDKs
|
||||
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
|
||||
if (CMAKE_UNAME)
|
||||
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
|
||||
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
|
||||
endif (CMAKE_UNAME)
|
||||
|
||||
# Force the compilers to gcc for iOS
|
||||
include (CMakeForceCompiler)
|
||||
#CMAKE_FORCE_C_COMPILER (/usr/bin/gcc Apple)
|
||||
set(CMAKE_C_COMPILER /usr/bin/clang)
|
||||
#CMAKE_FORCE_CXX_COMPILER (/usr/bin/g++ Apple)
|
||||
set(CMAKE_CXX_COMPILER /usr/bin/clang++)
|
||||
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
|
||||
|
||||
# Skip the platform compiler checks for cross compiling
|
||||
set (CMAKE_CXX_COMPILER_WORKS TRUE)
|
||||
set (CMAKE_C_COMPILER_WORKS TRUE)
|
||||
|
||||
# All iOS/Darwin specific settings - some may be redundant
|
||||
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||
set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
|
||||
set (CMAKE_SHARED_MODULE_PREFIX "lib")
|
||||
set (CMAKE_SHARED_MODULE_SUFFIX ".so")
|
||||
set (CMAKE_MODULE_EXISTS 1)
|
||||
set (CMAKE_DL_LIBS "")
|
||||
|
||||
set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
|
||||
set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
||||
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||
|
||||
# Hidden visibilty is required for cxx on iOS
|
||||
set (CMAKE_C_FLAGS_INIT "")
|
||||
set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden")
|
||||
|
||||
set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
|
||||
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
|
||||
|
||||
set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
|
||||
set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
|
||||
|
||||
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
|
||||
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
|
||||
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
|
||||
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
|
||||
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
|
||||
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||
|
||||
# Setup iOS platform unless specified manually with IOS_PLATFORM
|
||||
if (NOT DEFINED IOS_PLATFORM)
|
||||
set (IOS_PLATFORM "OS")
|
||||
endif (NOT DEFINED IOS_PLATFORM)
|
||||
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
|
||||
|
||||
# Setup building for arm64 or not
|
||||
if (NOT DEFINED BUILD_ARM64)
|
||||
set (BUILD_ARM64 true)
|
||||
endif (NOT DEFINED BUILD_ARM64)
|
||||
set (BUILD_ARM64 ${BUILD_ARM64} CACHE STRING "Build arm64 arch or not")
|
||||
|
||||
# Check the platform selection and setup for developer root
|
||||
if (${IOS_PLATFORM} STREQUAL "OS")
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
|
||||
set (SIMULATOR true)
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR64")
|
||||
set (SIMULATOR true)
|
||||
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
||||
|
||||
# This causes the installers to properly locate the output libraries
|
||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
||||
else (${IOS_PLATFORM} STREQUAL "OS")
|
||||
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
|
||||
endif (${IOS_PLATFORM} STREQUAL "OS")
|
||||
|
||||
# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT
|
||||
# Note Xcode 4.3 changed the installation location, choose the most recent one available
|
||||
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
|
||||
set (XCODE_POST_43_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
||||
set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
||||
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||
if (EXISTS ${XCODE_POST_43_ROOT})
|
||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
|
||||
elseif(EXISTS ${XCODE_PRE_43_ROOT})
|
||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
|
||||
endif (EXISTS ${XCODE_POST_43_ROOT})
|
||||
endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||
set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
|
||||
|
||||
# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
|
||||
if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
||||
file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
|
||||
if (_CMAKE_IOS_SDKS)
|
||||
list (SORT _CMAKE_IOS_SDKS)
|
||||
list (REVERSE _CMAKE_IOS_SDKS)
|
||||
list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
|
||||
else (_CMAKE_IOS_SDKS)
|
||||
message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
|
||||
endif (_CMAKE_IOS_SDKS)
|
||||
message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
|
||||
endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
||||
set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
|
||||
|
||||
# Set the sysroot default to the most recent SDK
|
||||
set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
|
||||
|
||||
# set the architecture for iOS
|
||||
if (${IOS_PLATFORM} STREQUAL "OS")
|
||||
set (IOS_ARCH armv7 armv7s arm64)
|
||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
|
||||
set (IOS_ARCH i386)
|
||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR64")
|
||||
set (IOS_ARCH x86_64)
|
||||
endif (${IOS_PLATFORM} STREQUAL "OS")
|
||||
|
||||
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
|
||||
|
||||
# Set the find root to the iOS developer roots and to user defined paths
|
||||
set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root")
|
||||
|
||||
# default to searching for frameworks first
|
||||
set (CMAKE_FIND_FRAMEWORK FIRST)
|
||||
|
||||
# set up the default search directories for frameworks
|
||||
set (CMAKE_SYSTEM_FRAMEWORK_PATH
|
||||
${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
|
||||
${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
|
||||
${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
|
||||
)
|
||||
|
||||
# only search the iOS sdks, not the remainder of the host filesystem
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
|
||||
# This little macro lets you set any XCode specific property
|
||||
macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
|
||||
set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
|
||||
endmacro (set_xcode_property)
|
||||
|
||||
|
||||
# This macro lets you find executable programs on the host system
|
||||
macro (find_host_package)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
|
||||
set (IOS FALSE)
|
||||
|
||||
find_package(${ARGN})
|
||||
|
||||
set (IOS TRUE)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
endmacro (find_host_package)
|
70
c_wrapper/src/cleaner.h
Executable file
70
c_wrapper/src/cleaner.h
Executable file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRC_CLEANER_H_
|
||||
#define SRC_CLEANER_H_
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <functional>
|
||||
using namespace std;
|
||||
|
||||
|
||||
class cleaner {
|
||||
public:
|
||||
cleaner(){}
|
||||
virtual ~cleaner(){
|
||||
lock_guard<recursive_mutex> lck(_mtx);
|
||||
for(auto &fun : _cleanInvokerList){
|
||||
fun();
|
||||
}
|
||||
_cleanInvokerList.clear();
|
||||
}
|
||||
static cleaner &Instance(){
|
||||
static cleaner *instance(new cleaner);
|
||||
return *instance;
|
||||
}
|
||||
static void Destory(){
|
||||
delete &Instance();
|
||||
}
|
||||
template<typename FUN>
|
||||
void push_front(FUN &&fun){
|
||||
lock_guard<recursive_mutex> lck(_mtx);
|
||||
_cleanInvokerList.push_front(fun);
|
||||
}
|
||||
|
||||
template<typename FUN>
|
||||
void push_back(FUN &&fun){
|
||||
lock_guard<recursive_mutex> lck(_mtx);
|
||||
_cleanInvokerList.push_back(fun);
|
||||
}
|
||||
|
||||
private:
|
||||
recursive_mutex _mtx;
|
||||
list<function<void()> > _cleanInvokerList;
|
||||
};
|
||||
|
||||
#endif /* SRC_CLEANER_H_ */
|
191
c_wrapper/src/common.cpp
Executable file
191
c_wrapper/src/common.cpp
Executable file
@ -0,0 +1,191 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <stdarg.h>
|
||||
#include <unordered_map>
|
||||
#include "Util/logger.h"
|
||||
#include "Util/onceToken.h"
|
||||
#include "Util/TimeTicker.h"
|
||||
#include "Network/TcpServer.h"
|
||||
#include "Poller/EventPoller.h"
|
||||
#include "Rtsp/UDPServer.h"
|
||||
#include "Rtsp/RtspSession.h"
|
||||
#include "Rtmp/RtmpSession.h"
|
||||
#include "Http/HttpSession.h"
|
||||
#include "cleaner.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZL::Util;
|
||||
using namespace ZL::Rtmp;
|
||||
using namespace ZL::Rtsp;
|
||||
using namespace ZL::Http;
|
||||
|
||||
static TcpServer<RtspSession>::Ptr s_pRtspSrv;
|
||||
static TcpServer<RtmpSession>::Ptr s_pRtmpSrv;
|
||||
static TcpServer<HttpSession>::Ptr s_pHttpSrv;
|
||||
|
||||
//////////////////////////environment init///////////////////////////
|
||||
|
||||
API_EXPORT void CALLTYPE onAppStart(){
|
||||
static onceToken s_token([](){
|
||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
||||
EventPoller::Instance(true);
|
||||
|
||||
cleaner::Instance().push_back([](){
|
||||
s_pRtspSrv.reset();
|
||||
s_pRtmpSrv.reset();
|
||||
s_pHttpSrv.reset();
|
||||
WorkThreadPool::Destory();
|
||||
UDPServer::Destory();
|
||||
AsyncTaskThread::Destory();
|
||||
EventPoller::Destory();
|
||||
DebugL << "clear common" << endl;
|
||||
Logger::Destory();
|
||||
});
|
||||
},nullptr);
|
||||
}
|
||||
|
||||
|
||||
API_EXPORT void CALLTYPE onAppExit(){
|
||||
cleaner::Destory();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE initHttpServer(unsigned short port){
|
||||
s_pHttpSrv.reset(new TcpServer<HttpSession>());
|
||||
try {
|
||||
s_pHttpSrv->start(port);
|
||||
return 0;
|
||||
} catch (std::exception &ex) {
|
||||
s_pHttpSrv.reset();
|
||||
WarnL << ex.what();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
API_EXPORT int CALLTYPE initRtspServer(unsigned short port) {
|
||||
s_pRtspSrv.reset(new TcpServer<RtspSession>());
|
||||
try {
|
||||
s_pRtspSrv->start(port);
|
||||
return 0;
|
||||
} catch (std::exception &ex) {
|
||||
s_pRtspSrv.reset();
|
||||
WarnL << ex.what();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE initRtmpServer(unsigned short port) {
|
||||
s_pRtmpSrv.reset(new TcpServer<RtmpSession>());
|
||||
try {
|
||||
s_pRtmpSrv->start(port);
|
||||
return 0;
|
||||
} catch (std::exception &ex) {
|
||||
s_pRtmpSrv.reset();
|
||||
WarnL << ex.what();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE listenEvent_onPlay(onEventPlay cb,void *userData){
|
||||
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtspSessionPlay,
|
||||
[cb,userData](BroadcastRtspSessionPlayArgs){
|
||||
static unordered_map<string, void *> s_timerKeyMap;
|
||||
static mutex s_mtx;
|
||||
uint64_t tag;
|
||||
{
|
||||
lock_guard<mutex> lck(s_mtx);
|
||||
//每个stream随机分配一个内存地址并且不重复
|
||||
tag = (uint64_t)&s_timerKeyMap[stream];
|
||||
}
|
||||
string appTmp(app);
|
||||
string streamTmp(stream);
|
||||
AsyncTaskThread::Instance().CancelTask(tag);
|
||||
int i = 2;
|
||||
AsyncTaskThread::Instance().DoTaskDelay(tag,50,[cb,userData,appTmp,streamTmp,i](){
|
||||
InfoL << "listenEvent_onPlay:" << appTmp << " " << streamTmp << " " << i;
|
||||
cb(userData,appTmp.data(),streamTmp.data());
|
||||
return (--const_cast<int &>(i)) > 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData){
|
||||
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtspSrcRegisted,
|
||||
[cb,userData](BroadcastRtspSrcRegistedArgs){
|
||||
cb(userData,app,stream);
|
||||
});
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData){
|
||||
NoticeCenter::Instance().addListener((void *)(cb),Config::Broadcast::kBroadcastRtmpSrcRegisted,
|
||||
[cb,userData](BroadcastRtmpSrcRegistedArgs){
|
||||
cb(userData,app,stream);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
API_EXPORT void CALLTYPE log_printf(LogType level,const char* file, const char* function, int line,const char *fmt,...){
|
||||
LogInfoMaker info((LogLevel)level,file,function,line);
|
||||
va_list pArg;
|
||||
va_start(pArg, fmt);
|
||||
char buf[4096];
|
||||
int n = vsprintf(buf, fmt, pArg);
|
||||
buf[n] = '\0';
|
||||
va_end(pArg);
|
||||
info << buf;
|
||||
}
|
||||
API_EXPORT void CALLTYPE log_setLevel(LogType level){
|
||||
Logger::Instance().setLevel((LogLevel)level);
|
||||
}
|
||||
|
||||
class LogoutChannel: public LogChannel {
|
||||
public:
|
||||
LogoutChannel(const string &name, onLogOut cb, LogLevel level = LDebug)
|
||||
:LogChannel(name, level, "%Y-%m-%d %H:%M:%S"){
|
||||
_cb = cb;
|
||||
}
|
||||
virtual ~LogoutChannel(){}
|
||||
void write(const LogInfo_ptr &logInfo){
|
||||
if (level() > logInfo->getLevel()) {
|
||||
return;
|
||||
}
|
||||
stringstream strStream;
|
||||
logInfo->format(strStream, timeFormat().data(), false);
|
||||
auto strTmp = strStream.str();
|
||||
if (_cb) {
|
||||
_cb(strTmp.data(), strTmp.size());
|
||||
}
|
||||
}
|
||||
private:
|
||||
onLogOut _cb = nullptr;
|
||||
};
|
||||
|
||||
API_EXPORT void CALLTYPE log_setOnLogOut(onLogOut cb){
|
||||
std::shared_ptr<LogoutChannel> chn(new LogoutChannel("LogoutChannel",cb,LTrace));
|
||||
Logger::Instance().add(chn);
|
||||
}
|
||||
|
||||
|
155
c_wrapper/src/common.h
Executable file
155
c_wrapper/src/common.h
Executable file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRC_COMMON_H_
|
||||
#define SRC_COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(MediaKitWrapper_EXPORTS)
|
||||
#define API_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define API_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#define CALLTYPE __cdecl
|
||||
#else
|
||||
#define API_EXPORT
|
||||
#define CALLTYPE
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/////////////////////////environment init////////////////////////////////
|
||||
API_EXPORT void CALLTYPE onAppStart();
|
||||
API_EXPORT void CALLTYPE onAppExit();
|
||||
|
||||
/*
|
||||
* 描述:创建Http服务器
|
||||
* 参数:port:htt监听端口,推荐80
|
||||
* 返回值:0:成功;-1:失败
|
||||
*/
|
||||
API_EXPORT int CALLTYPE initHttpServer(unsigned short port);
|
||||
|
||||
/*
|
||||
* 描述:创建RTSP服务器
|
||||
* 参数:port:rtsp监听端口,推荐554
|
||||
* 返回值:0:成功;-1:失败
|
||||
*/
|
||||
API_EXPORT int CALLTYPE initRtspServer(unsigned short port);
|
||||
|
||||
/*
|
||||
* 描述:创建RTMP服务器
|
||||
* 参数:port:rtmp监听端口,推荐1935
|
||||
* 返回值:0:成功;-1:失败
|
||||
*/
|
||||
API_EXPORT int CALLTYPE initRtmpServer(unsigned short port);
|
||||
|
||||
/*
|
||||
* 描述:播放事件回调函数定义
|
||||
* 参数:userData:用户数据指针strApp:应用名,strStream:流名称
|
||||
*/
|
||||
typedef void (CALLTYPE *onEventPlay)(void *userData,const char *strApp,const char *strStream);
|
||||
|
||||
/*
|
||||
* 描述:监听事件
|
||||
* 参数:cb:回调函数指针,userData:用户数据指针
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE listenEvent_onPlay(onEventPlay cb,void *userData);
|
||||
|
||||
/*
|
||||
* 描述:注册RTSP事件
|
||||
* 参数:userData:用户数据指针strApp:应用名,strStream:流名称
|
||||
*/
|
||||
typedef void (CALLTYPE *onEventRegistMediaSrc)(void *userData,const char *strApp,const char *strStream);
|
||||
|
||||
/*
|
||||
* 描述:监听事件
|
||||
* 参数:cb:回调函数指针,userData:用户数据指针
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE listenEvent_onRegistRtsp(onEventRegistMediaSrc cb,void *userData);
|
||||
|
||||
/*
|
||||
* 描述:监听事件
|
||||
* 参数:cb:回调函数指针,userData:用户数据指针
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE listenEvent_onRegistRtmp(onEventRegistMediaSrc cb,void *userData);
|
||||
|
||||
|
||||
/////////////////////////日志////////////////////////////////
|
||||
|
||||
typedef enum {
|
||||
//日志级别
|
||||
LogTrace = 0, LogDebug, LogInfo, LogWarn, LogError, LogFatal,
|
||||
} LogType;
|
||||
|
||||
typedef void(CALLTYPE *onLogOut)(const char *strLog, int iLogLen);
|
||||
|
||||
/*
|
||||
* 描述:设置Log输出回调
|
||||
* 参数:onLogOut:回调函数
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE log_setOnLogOut(onLogOut);
|
||||
|
||||
/*
|
||||
* 描述:设在日志显示级别
|
||||
* 参数:level:日志级别
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE log_setLevel(LogType level);
|
||||
|
||||
/*
|
||||
* 描述:打印日志
|
||||
* 参数:level:日志级别;file:文件名称,function:函数名称,line:所在行数,fmt:格式化字符串
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE log_printf(LogType level, const char* file, const char* function, int line, const char *fmt, ...);
|
||||
|
||||
|
||||
#define log_trace(fmt,...) log_printf(LogTrace,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)
|
||||
#define log_debug(fmt,...) log_printf(LogDebug,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)
|
||||
#define log_info(fmt,...) log_printf(LogInfo,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)
|
||||
#define log_warn(fmt,...) log_printf(LogWarn,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)
|
||||
#define log_error(fmt,...) log_printf(LogError,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)
|
||||
#define log_fatal(fmt,...) log_printf(LogFatal,__FILE__,__FUNCTION__,__LINE__,fmt,__VA_ARGS__)
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* SRC_COMMON_H_ */
|
73
c_wrapper/src/httpdownloader.cpp
Executable file
73
c_wrapper/src/httpdownloader.cpp
Executable file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "httpdownloader.h"
|
||||
|
||||
#include "Util/logger.h"
|
||||
#include "Util/TimeTicker.h"
|
||||
#include "Util/onceToken.h"
|
||||
#include "Http/HttpDownloader.h"
|
||||
#include "cleaner.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZL::Util;
|
||||
using namespace ZL::Http;
|
||||
|
||||
|
||||
static recursive_mutex s_mtxMapDownloader;
|
||||
static unordered_map<void *, HttpDownloader::Ptr> s_mapDownloader;
|
||||
|
||||
static onceToken s_token([](){
|
||||
cleaner::Instance().push_front([](){
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapDownloader);
|
||||
s_mapDownloader.clear();
|
||||
DebugL << "clear httpdownloader" << endl;
|
||||
});
|
||||
},nullptr);
|
||||
|
||||
|
||||
|
||||
API_EXPORT HttpDownloaderContex CALLTYPE createDownloader(){
|
||||
HttpDownloader::Ptr ret(new HttpDownloader());
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapDownloader);
|
||||
s_mapDownloader.emplace(ret.get(),ret);
|
||||
return ret.get();
|
||||
}
|
||||
API_EXPORT void CALLTYPE downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData){
|
||||
HttpDownloader *ptr = (HttpDownloader *)ctx;
|
||||
string urlTmp(url);
|
||||
ptr->startDownload(url, [cb,userData,urlTmp](int code,const char *errMsg,const char *filePath){
|
||||
if(cb){
|
||||
InfoL << code << " " << errMsg << " " << filePath << " " << urlTmp;
|
||||
cb(userData,code,errMsg,filePath);
|
||||
}
|
||||
});
|
||||
}
|
||||
API_EXPORT void CALLTYPE releaseDownloader(HttpDownloaderContex ctx){
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapDownloader);
|
||||
s_mapDownloader.erase(ctx);
|
||||
}
|
||||
|
49
c_wrapper/src/httpdownloader.h
Executable file
49
c_wrapper/src/httpdownloader.h
Executable file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRC_HTTPDOWNLOADER_H_
|
||||
#define SRC_HTTPDOWNLOADER_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////Httpdownloader/////////////////////////////////////////////////
|
||||
typedef void * HttpDownloaderContex;
|
||||
typedef void(CALLTYPE *downloader_onResult)(void *userData,int code,const char *errMsg,const char *filePath);
|
||||
|
||||
API_EXPORT HttpDownloaderContex CALLTYPE createDownloader();
|
||||
API_EXPORT void CALLTYPE downloader_startDownload(HttpDownloaderContex ctx,const char *url,downloader_onResult cb,void *userData);
|
||||
API_EXPORT void CALLTYPE releaseDownloader(HttpDownloaderContex ctx);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SRC_HTTPDOWNLOADER_H_ */
|
90
c_wrapper/src/media.cpp
Executable file
90
c_wrapper/src/media.cpp
Executable file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "media.h"
|
||||
#include "Util/logger.h"
|
||||
#include "Util/TimeTicker.h"
|
||||
#include "Util/onceToken.h"
|
||||
#include "Device/Device.h"
|
||||
#include "cleaner.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZL::DEV;
|
||||
using namespace ZL::Util;
|
||||
|
||||
static recursive_mutex s_mtxMapMedia;
|
||||
static unordered_map<void *, DevChannel::Ptr> s_mapMedia;
|
||||
|
||||
static onceToken s_token([](){
|
||||
cleaner::Instance().push_front([](){
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapMedia);
|
||||
s_mapMedia.clear();
|
||||
DebugL << "clear media" << endl;
|
||||
});
|
||||
},nullptr);
|
||||
|
||||
|
||||
|
||||
//////////////////////////Rtsp media///////////////////////////
|
||||
API_EXPORT MediaContext CALLTYPE createMedia(const char *appName,const char *mediaName) {
|
||||
DevChannel::Ptr ret(new DevChannel(appName,mediaName));
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapMedia);
|
||||
s_mapMedia.emplace((void *) (ret.get()), ret);
|
||||
return ret.get();
|
||||
}
|
||||
API_EXPORT void CALLTYPE releaseMedia(MediaContext ctx) {
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapMedia);
|
||||
s_mapMedia.erase(ctx);
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE media_initVideo(MediaContext ctx, int width, int height, int frameRate) {
|
||||
DevChannel *ptr = (DevChannel *) ctx;
|
||||
VideoInfo info;
|
||||
info.iFrameRate = frameRate;
|
||||
info.iWidth = width;
|
||||
info.iHeight = height;
|
||||
ptr->initVideo(info);
|
||||
}
|
||||
API_EXPORT void CALLTYPE media_initAudio(MediaContext ctx, int channel, int sampleBit, int sampleRate) {
|
||||
DevChannel *ptr = (DevChannel *) ctx;
|
||||
AudioInfo info;
|
||||
info.iSampleRate = sampleRate;
|
||||
info.iChannel = channel;
|
||||
info.iSampleBit = sampleBit;
|
||||
ptr->initAudio(info);
|
||||
}
|
||||
API_EXPORT void CALLTYPE media_inputH264(MediaContext ctx, void *data, int len, unsigned long stamp) {
|
||||
//TimeTicker();
|
||||
DevChannel *ptr = (DevChannel *) ctx;
|
||||
ptr->inputH264((char *) data, len, stamp);
|
||||
}
|
||||
API_EXPORT void CALLTYPE media_inputAAC(MediaContext ctx, void *data, int len,unsigned long stamp) {
|
||||
//TimeTicker();
|
||||
DevChannel *ptr = (DevChannel *) ctx;
|
||||
ptr->inputAAC((char *) data, len, stamp);
|
||||
}
|
||||
|
||||
|
87
c_wrapper/src/media.h
Executable file
87
c_wrapper/src/media.h
Executable file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRC_MEDIA_H_
|
||||
#define SRC_MEDIA_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////Rtsp media////////////////////////////////////////////
|
||||
|
||||
typedef void* MediaContext;
|
||||
/*
|
||||
* 描述:创建一个媒体源
|
||||
* 参数:mediaName:媒体名称,url地址的一部分
|
||||
* 返回值:媒体源句柄
|
||||
*/
|
||||
API_EXPORT MediaContext CALLTYPE createMedia(const char *appName,const char *mediaName);
|
||||
|
||||
/*
|
||||
* 描述:销毁媒体源
|
||||
* 参数:ctx:媒体源句柄
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE releaseMedia(MediaContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:初始化媒体源的视频信息
|
||||
* 参数:ctx:媒体源句柄;width:视频宽度;height:视频高度;frameRate:视频fps
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE media_initVideo(MediaContext ctx, int width, int height, int frameRate);
|
||||
|
||||
/*
|
||||
* 描述:初始化媒体源的音频信息
|
||||
* 参数:ctx:媒体源句柄;channel:声道数;sampleBit:音频采样位数,支持16bit;sampleRate:音频采样率
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE media_initAudio(MediaContext ctx, int channel, int sampleBit, int sampleRate);
|
||||
|
||||
/*
|
||||
* 描述:输入单帧H264视频,需要输入SPS和PPS帧,帧起始字节00 00 01,00 00 00 01均可
|
||||
* 参数:ctx:媒体源句柄;data:单帧H264数据;len:单帧H264数据字节数;stamp:时间戳,毫秒
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE media_inputH264(MediaContext ctx, void *data, int len, unsigned long stamp);
|
||||
|
||||
/*
|
||||
* 描述:输入单帧AAC音频(有adts头)
|
||||
* 参数:ctx:媒体源句柄;data:单帧AAC数据;len:单帧AAC数据字节数;stamp:时间戳,毫秒
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE media_inputAAC(MediaContext ctx, void *data, int len, unsigned long stamp);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SRC_MEDIA_H_ */
|
37
c_wrapper/src/mediakit.h
Executable file
37
c_wrapper/src/mediakit.h
Executable file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRC_RTSPAPI_H_
|
||||
#define SRC_RTSPAPI_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "httpdownloader.h"
|
||||
#include "media.h"
|
||||
#include "player.h"
|
||||
#include "proxyplayer.h"
|
||||
|
||||
|
||||
#endif /* SRC_RTSPAPI_H_ */
|
349
c_wrapper/src/player.cpp
Executable file
349
c_wrapper/src/player.cpp
Executable file
@ -0,0 +1,349 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "player.h"
|
||||
#include "Util/logger.h"
|
||||
#include "Util/TimeTicker.h"
|
||||
#include "Util/onceToken.h"
|
||||
#include "Thread/ThreadPool.h"
|
||||
#include "Poller/EventPoller.h"
|
||||
#include "Player/MediaPlayer.h"
|
||||
#include "H264/H264Parser.h"
|
||||
#include "cleaner.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace ZL::Util;
|
||||
using namespace ZL::Thread;
|
||||
using namespace ZL::Player;
|
||||
using namespace ZL::Rtmp;
|
||||
using namespace ZL::Rtsp;
|
||||
|
||||
static recursive_mutex s_mtxMapPlayer;
|
||||
static unordered_map<void *, MediaPlayer::Ptr> s_mapPlayer;
|
||||
|
||||
static onceToken s_token([](){
|
||||
cleaner::Instance().push_front([](){
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapPlayer);
|
||||
s_mapPlayer.clear();
|
||||
DebugL << "clear player" << endl;
|
||||
});
|
||||
},nullptr);
|
||||
|
||||
|
||||
////////////////////////rtsp player/////////////////////////////////////////
|
||||
#define getPlayer(ctx) \
|
||||
MediaPlayer::Ptr player;\
|
||||
{\
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapPlayer);\
|
||||
auto it = s_mapPlayer.find(ctx);\
|
||||
if(it != s_mapPlayer.end()){\
|
||||
player = it->second;\
|
||||
}\
|
||||
}
|
||||
API_EXPORT PlayerContext CALLTYPE createPlayer() {
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapPlayer);
|
||||
MediaPlayer::Ptr ret(new MediaPlayer());
|
||||
s_mapPlayer.emplace(ret.get(), ret);
|
||||
if(s_mapPlayer.size() > 16){
|
||||
FatalL << s_mapPlayer.size();
|
||||
}
|
||||
return ret.get();
|
||||
}
|
||||
API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
player_setOnGetAudio(ctx, nullptr, nullptr);
|
||||
player_setOnGetVideo(ctx, nullptr, nullptr);
|
||||
player_setOnPlayResult(ctx, nullptr, nullptr);
|
||||
player_setOnShutdown(ctx, nullptr, nullptr);
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapPlayer);
|
||||
s_mapPlayer.erase(ctx);
|
||||
|
||||
ASYNC_TRACE([player]() {
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapPlayer);
|
||||
player->teardown();
|
||||
});
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE player_setOptionInt(PlayerContext ctx,const char* key,int val){
|
||||
string keyTmp(key);
|
||||
ASYNC_TRACE([ctx,keyTmp,val](){
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
(*player)[keyTmp] = val;
|
||||
});
|
||||
}
|
||||
API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* key,const char *val){
|
||||
string keyTmp(key);
|
||||
string valTmp(val);
|
||||
ASYNC_TRACE([ctx,keyTmp,valTmp](){
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
(*player)[keyTmp] = valTmp;
|
||||
});
|
||||
}
|
||||
API_EXPORT void CALLTYPE player_play(PlayerContext ctx, const char* url) {
|
||||
string urlTmp(url);
|
||||
ASYNC_TRACE([ctx,urlTmp](){
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
player->play(urlTmp.data());
|
||||
});
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE player_pause(PlayerContext ctx, int pause) {
|
||||
ASYNC_TRACE([ctx,pause](){
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
player->pause(pause);
|
||||
});
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE player_seekTo(PlayerContext ctx, float fProgress) {
|
||||
ASYNC_TRACE([ctx,fProgress]() {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
return player->seekTo(fProgress);
|
||||
});
|
||||
}
|
||||
API_EXPORT void CALLTYPE player_setOnShutdown(PlayerContext ctx, player_onResult cb, void *userData) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
if(cb){
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnShutdown([cb,userData](const SockException &ex) {
|
||||
cb(userData,ex.getErrCode(),ex.what());
|
||||
});
|
||||
});
|
||||
}else{
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnShutdown(nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE player_setOnPlayResult(PlayerContext ctx, player_onResult cb, void *userData) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
if (cb) {
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnPlayResult([cb,userData](const SockException &ex) {
|
||||
cb(userData,ex.getErrCode(),ex.what());
|
||||
});
|
||||
});
|
||||
} else {
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnPlayResult(nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx, player_onGetH264 cb,
|
||||
void *userData) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
if (cb) {
|
||||
std::shared_ptr<H264Parser> pParser(new H264Parser());
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnVideoCB([cb,userData,pParser](const H264Frame &frame) {
|
||||
pParser->inputH264(frame.data, frame.timeStamp);
|
||||
cb(userData, (void *)frame.data.data(), frame.data.size(), frame.timeStamp,pParser->getPts());
|
||||
});
|
||||
});
|
||||
} else {
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnVideoCB(nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
API_EXPORT void CALLTYPE player_setOnGetAudio(PlayerContext ctx, player_onGetAAC cb,
|
||||
void *userData) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return;
|
||||
}
|
||||
if (cb) {
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnAudioCB([cb,userData](const AdtsFrame &frame) {
|
||||
cb(userData, (void *)frame.data, frame.aac_frame_length, frame.timeStamp);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
SYNC_TRACE([&](){
|
||||
player->setOnAudioCB(nullptr);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getVideoWidth(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getVideoWidth();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getVideoHeight(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getVideoHeight();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getVideoFps(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getVideoFps();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getAudioSampleRate(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getAudioSampleRate();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getAudioSampleBit(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getAudioSampleBit();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getAudioChannel();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx, char *buf, int bufsize) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
if (bufsize < (int) player->getPps().size() || player->getPps().empty()) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(buf, player->getPps().data(), player->getPps().size());
|
||||
return player->getPps().size();
|
||||
}
|
||||
API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx, char *buf, int bufsize) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
if (bufsize < (int) player->getSps().size() || player->getSps().empty()) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(buf, player->getSps().data(), player->getSps().size());
|
||||
return player->getSps().size();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx, char *buf, int bufsize) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
if (bufsize < (int) player->getAudioCfg().size()) {
|
||||
return -1;
|
||||
}
|
||||
memcpy(buf, player->getAudioCfg().data(), player->getAudioCfg().size());
|
||||
return player->getAudioCfg().size();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->containAudio();
|
||||
|
||||
}
|
||||
API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->containVideo();
|
||||
}
|
||||
|
||||
API_EXPORT int CALLTYPE player_isInited(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->isInited();
|
||||
}
|
||||
API_EXPORT float CALLTYPE player_getDuration(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getDuration();
|
||||
}
|
||||
|
||||
API_EXPORT float CALLTYPE player_getProgress(PlayerContext ctx) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getProgress();
|
||||
}
|
||||
|
||||
API_EXPORT float CALLTYPE player_getLossRate(PlayerContext ctx, int trackId) {
|
||||
getPlayer(ctx);
|
||||
if (!player) {
|
||||
return -1;
|
||||
}
|
||||
return player->getRtpLossRate(trackId);
|
||||
}
|
||||
|
235
c_wrapper/src/player.h
Executable file
235
c_wrapper/src/player.h
Executable file
@ -0,0 +1,235 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRC_PLAYER_H_
|
||||
#define SRC_PLAYER_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////RTSP Player/////////////////////////////////////////////////
|
||||
typedef void* PlayerContext;
|
||||
typedef void(CALLTYPE *player_onResult)(void *userData,int errCode,const char *errMsg);
|
||||
typedef void(CALLTYPE *player_onGetAAC)(void *userData,void *data,int len,unsigned long timeStamp);
|
||||
typedef void(CALLTYPE *player_onGetH264)(void *userData,void *data,int len,unsigned long dts,unsigned long pts);
|
||||
/*
|
||||
* 描述:创建一个Rtsp播放器
|
||||
* 参数:无
|
||||
* 返回值:Rtsp播放器句柄
|
||||
*/
|
||||
API_EXPORT PlayerContext CALLTYPE createPlayer();
|
||||
|
||||
/*
|
||||
* 描述:销毁一个播放器
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE releasePlayer(PlayerContext ctx);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:设置播放器配置选项
|
||||
* 参数: ctx:播放器句柄
|
||||
* key:配置项键,例如 rtp_type
|
||||
* val:值,例如 //设置rtp传输类型,可选项有0(tcp,默认)、1(udp)、2(组播)
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_setOptionInt(PlayerContext ctx,const char* key,int val);
|
||||
API_EXPORT void CALLTYPE player_setOptionString(PlayerContext ctx,const char* key,const char *val);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:播放rtsp链接(仅支持H264与AAC负载)
|
||||
* 参数: ctx:播放器句柄
|
||||
* url:rtsp链接
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_play(PlayerContext ctx,const char* url);
|
||||
|
||||
/*
|
||||
* 描述:暂停播放RTSP
|
||||
* 参数:ctx:播放器句柄;pause:1:暂停播放,0:恢复播放
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_pause(PlayerContext ctx,int pause);
|
||||
|
||||
/*
|
||||
* 描述:设置播放器异常停止回调函数
|
||||
* 参数:ctx:播放器句柄;cb:回调函数指针;userData:用户数据指针
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_setOnShutdown(PlayerContext ctx,player_onResult cb,void *userData);
|
||||
|
||||
/*
|
||||
* 描述:设置播放器播放结果回调函数
|
||||
* 参数:ctx:播放器句柄,cb:回调函数指针;userData:用户数据指针
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_setOnPlayResult(PlayerContext ctx,player_onResult cb,void *userData);
|
||||
|
||||
/*
|
||||
* 描述:设置播放器收到视频帧回调,I帧前为SPS,PPS帧;每帧包含00 00 00 01的帧头
|
||||
* 参数:ctx:播放器句柄,cb:回调函数指针;userData:用户数据指针
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_setOnGetVideo(PlayerContext ctx,player_onGetH264 cb,void *userData);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:设置播放器收到音频帧回调,每帧数据包含ADTS头
|
||||
* 参数:ctx:播放器句柄,cb:回调函数指针;userData:用户数据指针
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_setOnGetAudio(PlayerContext ctx,player_onGetAAC cb,void *userData);
|
||||
|
||||
/*
|
||||
* 描述:获取视频宽度
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:视频宽度
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getVideoWidth(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:获取视频高度
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:视频高度
|
||||
*/
|
||||
API_EXPORT int CALLTYPE CALLTYPE player_getVideoHeight(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:获取视频帧率
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:视频帧率
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getVideoFps(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:获取音频采样率
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:音频采样率
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getAudioSampleRate(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:获取音频采样位数(8bit或16bit)
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:音频采样位数
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getAudioSampleBit(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:获取音频通道数(单声道1,双声道2)
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:音频通道数
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getAudioChannel(PlayerContext ctx);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:获取H264的PPS帧
|
||||
* 参数:ctx:播放器句柄,buf:存放PPS数据的缓存;bufsize:缓存大小
|
||||
* 返回值:帧数据长度
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getH264PPS(PlayerContext ctx,char *buf,int bufsize);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:获取H264的SPS帧
|
||||
* 参数:ctx:播放器句柄,buf:存放SPS数据的缓存;bufsize:缓存大小
|
||||
* 返回值:帧数据长度
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getH264SPS(PlayerContext ctx,char *buf,int bufsize);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:获取AAC编码配置信息
|
||||
* 参数:ctx:播放器句柄;buf:存放CFG数据的缓存;bufsize:缓存大小
|
||||
* 返回值:CFG数据长度
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_getAacCfg(PlayerContext ctx,char *buf,int bufsize);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:是否包含音频数据
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:1:包含,0:不包含
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_containAudio(PlayerContext ctx);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:是否包含视频数据
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:1:包含,0:不包含
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_containVideo(PlayerContext ctx);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:是否已经初始化完成(获取完整的播放信息)
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:1:初始化完成,0:未完成
|
||||
*/
|
||||
API_EXPORT int CALLTYPE player_isInited(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:获取点播的时间长度,单位为秒(小于等于0,说明是直播,否则为点播)
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:点播的时间长度,单位秒
|
||||
*/
|
||||
API_EXPORT float CALLTYPE player_getDuration(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:获取点播播放进度
|
||||
* 参数:ctx:播放器句柄
|
||||
* 返回值:点播播放进度,取值范围未 0.0~1.0
|
||||
*/
|
||||
API_EXPORT float CALLTYPE player_getProgress(PlayerContext ctx);
|
||||
|
||||
/*
|
||||
* 描述:设置点播播放进度
|
||||
* 参数:ctx:播放器句柄;fProgress:播放进度,取值范围未 0.0~1.0
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE player_seekTo(PlayerContext ctx, float fProgress);
|
||||
|
||||
/*
|
||||
* 描述:获取丢包率
|
||||
* 参数:ctx:播放器句柄;trackId:如果是-1,则返回总丢包率,否则返回视频或者音频的丢包率
|
||||
* 返回值:丢包率
|
||||
*/
|
||||
API_EXPORT float CALLTYPE player_getLossRate(PlayerContext ctx,int trackId);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SRC_PLAYER_H_ */
|
60
c_wrapper/src/proxyplayer.cpp
Normal file
60
c_wrapper/src/proxyplayer.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "cleaner.h"
|
||||
#include "proxyplayer.h"
|
||||
#include "Device/PlayerProxy.h"
|
||||
#include "Util/onceToken.h"
|
||||
|
||||
using namespace ZL::DEV;
|
||||
using namespace ZL::Util;
|
||||
|
||||
static recursive_mutex s_mtxMapProxyPlayer;
|
||||
static unordered_map<void *, PlayerProxy::Ptr> s_mapProxyPlayer;
|
||||
|
||||
static onceToken s_token([](){
|
||||
cleaner::Instance().push_front([](){
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapProxyPlayer);
|
||||
s_mapProxyPlayer.clear();
|
||||
DebugL << "clear proxyplayer" << endl;
|
||||
});
|
||||
},nullptr);
|
||||
|
||||
API_EXPORT ProxyPlayerContext CALLTYPE createProxyPlayer(const char *app,const char *stream,int rtp_type){
|
||||
PlayerProxy::Ptr ret(new PlayerProxy(app,stream));
|
||||
(*ret)[RtspPlayer::kRtpType] = rtp_type;
|
||||
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapProxyPlayer);
|
||||
s_mapProxyPlayer.emplace(ret.get(),ret);
|
||||
return ret.get();
|
||||
}
|
||||
API_EXPORT void CALLTYPE releaseProxyPlayer(ProxyPlayerContext ctx){
|
||||
lock_guard<recursive_mutex> lck(s_mtxMapProxyPlayer);
|
||||
s_mapProxyPlayer.erase(ctx);
|
||||
}
|
||||
API_EXPORT void CALLTYPE proxyPlayer_play(ProxyPlayerContext ctx,const char *url){
|
||||
PlayerProxy *ptr = (PlayerProxy *)ctx;
|
||||
ptr->play(url);
|
||||
}
|
67
c_wrapper/src/proxyplayer.h
Normal file
67
c_wrapper/src/proxyplayer.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRC_PROXYPLAYER_H_
|
||||
#define SRC_PROXYPLAYER_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void* ProxyPlayerContext;
|
||||
|
||||
/*
|
||||
* 描述:创建一个代理播放器
|
||||
* 参数:app:应用名,生成url的一部分,rtsp://127.0.0.1/app/xxxx
|
||||
* stream:媒体流名,生成url的一部分,rtsp://127.0.0.1/xxxx/stream
|
||||
* rtp_type:如果播放的是rtsp连接则通过该参数配置设置rtp传输方式:RTP_TCP = 0, RTP_UDP = 1, RTP_MULTICAST = 2
|
||||
* 返回值:代理播放器句柄
|
||||
*/
|
||||
API_EXPORT ProxyPlayerContext CALLTYPE createProxyPlayer(const char *app,const char *stream,int rtp_type);
|
||||
|
||||
/*
|
||||
* 描述:销毁代理播放器
|
||||
* 参数:ctx:代理播放器句柄
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE releaseProxyPlayer(ProxyPlayerContext ctx);
|
||||
|
||||
|
||||
/*
|
||||
* 描述:开始播放
|
||||
* 参数:url:rtsp/rtmp连接
|
||||
* 返回值:无
|
||||
*/
|
||||
API_EXPORT void CALLTYPE proxyPlayer_play(ProxyPlayerContext ctx,const char *url);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SRC_PROXYPLAYER_H_ */
|
15
c_wrapper/tests/CMakeLists.txt
Normal file
15
c_wrapper/tests/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
aux_source_directory(. TEST_SRC_LIST)
|
||||
foreach(TEST_SRC ${TEST_SRC_LIST})
|
||||
STRING(REGEX REPLACE "^\\./|\\.c[a-zA-Z0-9_]*$" "" TEST_EXE_NAME ${TEST_SRC})
|
||||
message(STATUS "添加测试程序:${TEST_EXE_NAME}")
|
||||
add_executable(${TEST_EXE_NAME} ${TEST_SRC})
|
||||
|
||||
if(ANDROID)
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_static ${LINK_LIB_LIST})
|
||||
elseif(WIN32)
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST})
|
||||
else()
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST} pthread)
|
||||
endif()
|
||||
|
||||
endforeach(TEST_SRC ${TEST_SRC_LIST})
|
125
c_wrapper/tests/test_all.cpp
Normal file
125
c_wrapper/tests/test_all.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2016 xiongziliang <771730766@qq.com>
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
#include "mediakit.h"
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
void *media = nullptr;
|
||||
|
||||
int main(int argc,char *argv[]){
|
||||
//设置退出信号处理函数
|
||||
signal(SIGINT, [](int){});
|
||||
////////init environment////////////////////////////////////////////////////////////////
|
||||
onAppStart();
|
||||
////////init service/////////////////////////////////////////////////////////////////////
|
||||
initHttpServer(80);
|
||||
initRtmpServer(1935);
|
||||
initRtspServer(554);
|
||||
////////ProxyPlayer////////////////////////////////////////////////////////////////////////
|
||||
auto proxy = createProxyPlayer("app","proxy",0);
|
||||
proxyPlayer_play(proxy,"rtmp://live.hkstv.hk.lxdns.com/live/hks");
|
||||
log_warn("%s","请打开vlc播放:rtsp://127.0.0.1/app/proxy "
|
||||
"rtmp://127.0.0.1/app/proxy "
|
||||
"http://127.0.0.1/app/proxy/hls.m3u8");
|
||||
////////http downloader////////////////////////////////////////////////////////////////////
|
||||
auto downloader = createDownloader();
|
||||
downloader_startDownload(downloader,
|
||||
"http://pic4.nipic.com/20091121/3764872_215617048242_2.jpg",
|
||||
[](void *userData,int code,const char *errMsg,const char *filePath){
|
||||
log_info("下载结果:%d-%s:%s",code,errMsg,filePath);
|
||||
}, downloader);
|
||||
////////player//////////////////////////////////////////////////////////////////////////////
|
||||
auto player = createPlayer();
|
||||
|
||||
player_setOnPlayResult(player,[](void *userData,int errCode,const char *errMsg){
|
||||
log_info("播放结果:%d-%s",errCode,errMsg);
|
||||
|
||||
////////media/////////////////////////////////////////////////////////////////////////////////
|
||||
if(errCode){
|
||||
//play failed
|
||||
return;
|
||||
}
|
||||
auto player = userData;
|
||||
media = createMedia("app","media");
|
||||
if(player_containAudio(player) == 1){
|
||||
media_initAudio(media,
|
||||
player_getAudioChannel(player),
|
||||
player_getAudioSampleBit(player),
|
||||
player_getAudioSampleRate(player));
|
||||
}
|
||||
|
||||
if(player_containVideo(player) == 1){
|
||||
media_initVideo(media,
|
||||
player_getVideoWidth(player),
|
||||
player_getVideoHeight(player),
|
||||
player_getVideoFps(player));
|
||||
}
|
||||
log_warn("%s","请打开vlc播放:rtsp://127.0.0.1/app/media "
|
||||
"rtmp://127.0.0.1/app/media "
|
||||
"http://127.0.0.1/app/media/hls.m3u8");
|
||||
},player);
|
||||
|
||||
player_setOnShutdown(player,[](void *userData,int errCode,const char *errMsg){
|
||||
log_info("播放器异常断开:%d-%s",errCode,errMsg);
|
||||
|
||||
if(media){
|
||||
releaseMedia(media);
|
||||
}
|
||||
},player);
|
||||
|
||||
player_setOnGetAudio(player,[](void *userData,void *data,int len,unsigned long timeStamp){
|
||||
//在此解码视频
|
||||
//TO-DO
|
||||
//log_trace("audio:%d-%d",len,timeStamp);
|
||||
|
||||
////////输入aac///////////
|
||||
if(media){
|
||||
media_inputAAC(media,data,len,timeStamp);
|
||||
}
|
||||
},player);
|
||||
|
||||
player_setOnGetVideo(player,[](void *userData,void *data,int len,unsigned long dts,unsigned long pts){
|
||||
//在此解码音频
|
||||
//TO-DO
|
||||
//log_trace("video:%d-%d-%d",len,dts,pts);
|
||||
|
||||
////////输入264///////////
|
||||
if(media){
|
||||
media_inputH264(media,data,len,dts);
|
||||
}
|
||||
},player);
|
||||
|
||||
player_play(player,"rtmp://live.hkstv.hk.lxdns.com/live/hks");
|
||||
|
||||
|
||||
//sleep forever
|
||||
sleep(UINT32_MAX);
|
||||
////////uninit environment////////////////////////////////////////////////////////////////////
|
||||
onAppExit();
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user