mirror of
https://github.com/UltraCoderRU/libwebrtc.git
synced 2026-01-28 11:15:13 +00:00
Win32: Add Win32Console.cpp, temporary fix for merge script
Signed-off-by: Axel Isouard <axel@isouard.fr>
This commit is contained in:
parent
32f637a95d
commit
3bca34b165
6 changed files with 338 additions and 11 deletions
|
|
@ -4,6 +4,9 @@ project(libwebrtc)
|
|||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
|
||||
${CMAKE_SOURCE_DIR}/CMakeModules)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
find_package(DepotTools REQUIRED)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,10 @@ project(PeerConnection)
|
|||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
find_package(X11 REQUIRED)
|
||||
endif(UNIX AND NOT APPLE)
|
||||
|
||||
set(PEERCONNECTION_SOURCE_FILES
|
||||
main.cpp
|
||||
|
|
@ -27,15 +30,17 @@ set(PEERCONNECTION_HEADER_FILES
|
|||
SetRemoteSessionDescriptionObserver.h
|
||||
)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/out/src)
|
||||
include_directories(${CMAKE_BINARY_DIR}/src)
|
||||
|
||||
if(WIN)
|
||||
add_definitions(-DWEBRTC_WIN)
|
||||
else(WIN)
|
||||
if(WIN32)
|
||||
add_definitions(-DWEBRTC_WIN -DNOMINMAX)
|
||||
set(PEERCONNECTION_SOURCE_FILES ${PEERCONNECTION_SOURCE_FILES}
|
||||
Win32Console.cpp)
|
||||
else(WIN32)
|
||||
add_definitions(-DWEBRTC_POSIX -std=gnu++0x -D_GLIBCXX_USE_CXX11_ABI=0)
|
||||
set(PEERCONNECTION_SOURCE_FILES ${PEERCONNECTION_SOURCE_FILES}
|
||||
UnixConsole.cpp)
|
||||
endif(WIN)
|
||||
endif(WIN32)
|
||||
|
||||
add_executable(PeerConnection
|
||||
${PEERCONNECTION_SOURCE_FILES}
|
||||
|
|
@ -43,10 +48,12 @@ add_executable(PeerConnection
|
|||
|
||||
set(PEERCONNECTION_LIBRARIES ${LIBWEBRTC_LIBRARY_PATH} Threads::Threads)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
if(WIN32)
|
||||
set(PEERCONNECTION_LIBRARIES ${PEERCONNECTION_LIBRARIES} msdmo.lib wmcodecdspuuid.lib dmoguids.lib ole32.lib secur32.lib)
|
||||
elseif(UNIX AND NOT APPLE)
|
||||
set(PEERCONNECTION_LIBRARIES ${PEERCONNECTION_LIBRARIES}
|
||||
${X11_LIBRARIES}
|
||||
${CMAKE_DL_LIBS})
|
||||
endif(UNIX AND NOT APPLE)
|
||||
endif(WIN32)
|
||||
|
||||
target_link_libraries(PeerConnection ${PEERCONNECTION_LIBRARIES})
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@
|
|||
//
|
||||
|
||||
#include "webrtc/base/ssladapter.h"
|
||||
#ifdef WIN32
|
||||
#include "webrtc/base/win32socketinit.h"
|
||||
#include "webrtc/base/win32socketserver.h"
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#include "Core.h"
|
||||
|
||||
rtc::Thread *Core::_signalingThread = NULL;
|
||||
|
|
@ -10,6 +15,12 @@ rtc::Thread *Core::_workerThread = NULL;
|
|||
webrtc::PeerConnectionFactoryInterface *Core::_peerConnectionFactory = NULL;
|
||||
|
||||
bool Core::Init() {
|
||||
#if 0
|
||||
rtc::EnsureWinsockInit();
|
||||
rtc::Win32Thread w32_thread;
|
||||
rtc::ThreadManager::Instance()->SetCurrentThread(&w32_thread);
|
||||
#endif
|
||||
|
||||
rtc::InitializeSSL();
|
||||
rtc::InitRandom(rtc::Time());
|
||||
rtc::ThreadManager::Instance()->WrapCurrentThread();
|
||||
|
|
|
|||
195
Samples/PeerConnection/Win32Console.cpp
Normal file
195
Samples/PeerConnection/Win32Console.cpp
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
#include <iostream>
|
||||
#include <cstdarg>
|
||||
#include <Windows.h>
|
||||
#include "Console.h"
|
||||
|
||||
#define MAX_EDIT_LINE 32768
|
||||
|
||||
static HANDLE hOUT;
|
||||
static HANDLE hIN;
|
||||
|
||||
static DWORD dMode;
|
||||
static WORD wAttrib;
|
||||
static CONSOLE_CURSOR_INFO cursorInfo;
|
||||
|
||||
static size_t cursor;
|
||||
static std::string buffer;
|
||||
|
||||
bool Console::Init() {
|
||||
CONSOLE_CURSOR_INFO curs;
|
||||
CONSOLE_SCREEN_BUFFER_INFO info;
|
||||
|
||||
hIN = GetStdHandle(STD_INPUT_HANDLE);
|
||||
if (hIN == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hOUT = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (hOUT == INVALID_HANDLE_VALUE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GetConsoleMode(hIN, &dMode);
|
||||
SetConsoleMode(hIN, dMode & ~ENABLE_MOUSE_INPUT);
|
||||
|
||||
FlushConsoleInputBuffer(hIN);
|
||||
|
||||
GetConsoleScreenBufferInfo(hOUT, &info);
|
||||
wAttrib = info.wAttributes;
|
||||
|
||||
GetConsoleCursorInfo(hOUT, &cursorInfo);
|
||||
curs.dwSize = 1;
|
||||
curs.bVisible = FALSE;
|
||||
SetConsoleCursorInfo(hOUT, &curs);
|
||||
|
||||
cursor = 0;
|
||||
buffer.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Console::Update(std::string &input) {
|
||||
INPUT_RECORD *buff;
|
||||
DWORD count;
|
||||
DWORD events;
|
||||
char key;
|
||||
int newline = -1;
|
||||
int i;
|
||||
|
||||
input.clear();
|
||||
if (!GetNumberOfConsoleInputEvents(hIN, &events)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (events < 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
buff = new INPUT_RECORD[events];
|
||||
if (!ReadConsoleInput(hIN, buff, events, &count)) {
|
||||
delete[] buff;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (count < 1) {
|
||||
delete[] buff;
|
||||
return true;
|
||||
}
|
||||
|
||||
FlushConsoleInputBuffer(hIN);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (buff[i].EventType != KEY_EVENT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!buff[i].Event.KeyEvent.bKeyDown) {
|
||||
continue;
|
||||
}
|
||||
|
||||
key = buff[i].Event.KeyEvent.wVirtualKeyCode;
|
||||
|
||||
if (key == VK_RETURN) {
|
||||
newline = i;
|
||||
break;
|
||||
} else if (key == VK_BACK) {
|
||||
buffer.erase(--cursor, 1);
|
||||
}
|
||||
|
||||
char c = buff[i].Event.KeyEvent.uChar.AsciiChar;
|
||||
|
||||
if (c) {
|
||||
cursor++;
|
||||
buffer.append(1, c);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] buff;
|
||||
Console::Show();
|
||||
|
||||
if (newline < 0) {
|
||||
return true;
|
||||
}
|
||||
newline = 0;
|
||||
|
||||
if (!buffer.length())
|
||||
{
|
||||
std::cout << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::cout << buffer.c_str() << std::endl;
|
||||
|
||||
input = buffer;
|
||||
cursor = 0;
|
||||
buffer.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Console::Cleanup() {
|
||||
SetConsoleMode(hIN, dMode);
|
||||
SetConsoleCursorInfo(hOUT, &cursorInfo);
|
||||
CloseHandle(hOUT);
|
||||
CloseHandle(hIN);
|
||||
}
|
||||
|
||||
void Console::Reset(int num) {
|
||||
Console::Init();
|
||||
}
|
||||
|
||||
void Console::Show() {
|
||||
int i;
|
||||
CONSOLE_SCREEN_BUFFER_INFO binfo;
|
||||
COORD writeSize = { MAX_EDIT_LINE, 1 };
|
||||
COORD writePos = { 0, 0 };
|
||||
SMALL_RECT writeArea = { 0, 0, 0, 0 };
|
||||
CHAR_INFO line[MAX_EDIT_LINE];
|
||||
|
||||
GetConsoleScreenBufferInfo(hOUT, &binfo);
|
||||
|
||||
if (binfo.dwCursorPosition.X != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
writeArea.Left = 0;
|
||||
writeArea.Top = binfo.dwCursorPosition.Y;
|
||||
writeArea.Bottom = binfo.dwCursorPosition.Y;
|
||||
writeArea.Right = MAX_EDIT_LINE;
|
||||
|
||||
for (i = 0; i < MAX_EDIT_LINE; i++) {
|
||||
if (i < buffer.length())
|
||||
line[i].Char.AsciiChar = buffer.at(i);
|
||||
else
|
||||
line[i].Char.AsciiChar = ' ';
|
||||
|
||||
line[i].Attributes = wAttrib;
|
||||
}
|
||||
|
||||
if (buffer.length() > binfo.srWindow.Right) {
|
||||
WriteConsoleOutput(hOUT, line + (buffer.length() - binfo.srWindow.Right),
|
||||
writeSize, writePos, &writeArea);
|
||||
} else {
|
||||
WriteConsoleOutput(hOUT, line, writeSize, writePos, &writeArea);
|
||||
}
|
||||
}
|
||||
|
||||
void Console::Hide() {
|
||||
}
|
||||
|
||||
void Console::Print(const std::string &fmt, ...) {
|
||||
va_list argptr;
|
||||
char string[1024];
|
||||
|
||||
if (!fmt.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(argptr, fmt);
|
||||
vsnprintf(string, sizeof(string), fmt.c_str(), argptr);
|
||||
va_end(argptr);
|
||||
|
||||
std::cout << string << std::endl;
|
||||
Console::Show();
|
||||
}
|
||||
|
||||
void Console::Back() {
|
||||
}
|
||||
|
|
@ -8,8 +8,18 @@ set(LIBWEBRTC_GEN_ARGS use_gold=false)
|
|||
|
||||
if (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS} is_debug=false)
|
||||
elseif (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS} is_debug=true)
|
||||
endif (NOT CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||
|
||||
if (WIN32)
|
||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS})
|
||||
elseif (APPLE)
|
||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS})
|
||||
elseif (UNIX AND NOT APPLE)
|
||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS})
|
||||
endif (WIN32)
|
||||
|
||||
if (NOT BUILD_TESTS)
|
||||
set(LIBWEBRTC_GEN_ARGS ${LIBWEBRTC_GEN_ARGS} rtc_include_tests=false)
|
||||
endif (NOT BUILD_TESTS)
|
||||
|
|
@ -44,11 +54,11 @@ add_libwebrtc_command(libwebrtc_build
|
|||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${LIBWEBRTC_INSTALL_LIB_DIR})
|
||||
|
||||
set(MERGE_COMMAND
|
||||
python ${CMAKE_SOURCE_DIR}/merge_libs_wrapper.py src/out/Default ${LIBWEBRTC_LIBRARY_PATH})
|
||||
python ${CMAKE_SOURCE_DIR}/merge_libs_wrapper.py . ${LIBWEBRTC_LIBRARY_PATH})
|
||||
|
||||
add_libwebrtc_command(libwebrtc_merge
|
||||
${LIBWEBRTC_LIBRARY_PATH}
|
||||
"${MERGE_COMMAND}"
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}/src/out/Default/obj
|
||||
"Merging libraries into ${LIBWEBRTC_LIBRARY_NAME}"
|
||||
libwebrtc_build)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,19 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
# Searches for libraries or object files on the specified path and merges them
|
||||
# them into a single library. Assumes ninja is used on all platforms.
|
||||
|
||||
import fnmatch
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import vs_toolchain
|
||||
|
||||
|
|
@ -6,4 +21,90 @@ if sys.platform == 'win32':
|
|||
vs_toolchain.GetToolchainDir()
|
||||
os.environ['PATH'] += os.pathsep + os.environ['GYP_MSVS_OVERRIDE_PATH'] + '\\VC\\bin'
|
||||
|
||||
execfile('src/webrtc/build/merge_libs.py')
|
||||
IGNORE_PATTERNS = ['do_not_use', 'protoc', 'genperf']
|
||||
|
||||
def FindFiles(path, pattern):
|
||||
"""Finds files matching |pattern| under |path|.
|
||||
|
||||
Returns a list of file paths matching |pattern|, by walking the directory tree
|
||||
under |path|. Filenames containing the string 'do_not_use' or 'protoc' are
|
||||
excluded.
|
||||
|
||||
Args:
|
||||
path: The root path for the search.
|
||||
pattern: A shell-style wildcard pattern to match filenames against.
|
||||
(e.g. '*.a')
|
||||
|
||||
Returns:
|
||||
A list of file paths, relative to the current working directory.
|
||||
"""
|
||||
files = []
|
||||
for root, _, filenames in os.walk(path):
|
||||
for filename in fnmatch.filter(filenames, pattern):
|
||||
if all(pattern not in filename for pattern in IGNORE_PATTERNS):
|
||||
# We use the relative path here to avoid "argument list too
|
||||
# long" errors on Linux. Note: This doesn't always work, so
|
||||
# we use the find command on Linux.
|
||||
files.append(os.path.relpath(os.path.join(root, filename)))
|
||||
return files
|
||||
|
||||
def chunks(l, n):
|
||||
"""Yield successive n-sized chunks from l."""
|
||||
for i in range(0, len(l), n):
|
||||
yield l[i:i + n]
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) != 3:
|
||||
sys.stderr.write('Usage: ' + argv[0] + ' <search_path> <output_lib>\n')
|
||||
return 1
|
||||
|
||||
search_path = os.path.normpath(argv[1])
|
||||
output_lib = os.path.normpath(argv[2])
|
||||
|
||||
if not os.path.exists(search_path):
|
||||
sys.stderr.write('search_path does not exist: %s\n' % search_path)
|
||||
return 1
|
||||
|
||||
if os.path.isfile(output_lib):
|
||||
os.remove(output_lib)
|
||||
|
||||
if sys.platform.startswith('linux'):
|
||||
pattern = '*.o'
|
||||
cmd = 'ar crs'
|
||||
elif sys.platform == 'darwin':
|
||||
pattern = '*.a'
|
||||
cmd = 'libtool -static -v -o '
|
||||
elif sys.platform == 'win32':
|
||||
pattern = '*.lib'
|
||||
cmd = 'lib /OUT:'
|
||||
else:
|
||||
sys.stderr.write('Platform not supported: %r\n\n' % sys.platform)
|
||||
return 1
|
||||
|
||||
if sys.platform.startswith('linux'):
|
||||
cmd = ' '.join(['find', search_path, '-name "' + pattern + '"' +
|
||||
' -and -not -name ' +
|
||||
' -and -not -name '.join(IGNORE_PATTERNS) +
|
||||
' -exec', cmd, output_lib, '{} +'])
|
||||
else:
|
||||
cmd = ' '.join([cmd + output_lib] + FindFiles(search_path, pattern))
|
||||
print cmd
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
|
||||
if sys.platform == 'win32':
|
||||
filesList = list(chunks(FindFiles(search_path + '\\third_party\\libvpx', '*.obj'), 100))
|
||||
for files in filesList:
|
||||
cmd = ' '.join(['lib /OUT:' + output_lib] + [output_lib] + files)
|
||||
print cmd
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
filesList = list(chunks(FindFiles(search_path + '\\third_party\\jsoncpp', '*.obj'), 100))
|
||||
for files in filesList:
|
||||
cmd = ' '.join(['lib /OUT:' + output_lib] + [output_lib] + files)
|
||||
print cmd
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue