├── Android.mk ├── CMakeLists.txt ├── README.md ├── build ├── NUL_ ├── android │ ├── CMakeCache.android.initial.cmake │ ├── README.android │ ├── android.toolchain.cmake │ └── scripts │ │ ├── build.cmd │ │ ├── cmake_android.cmd │ │ ├── cmake_android.sh │ │ ├── cmake_android_armeabi.sh │ │ ├── cmake_android_neon.sh │ │ ├── package.sh │ │ └── wincfg.cmd.tmpl ├── cmake │ ├── Boost.cmake │ ├── Function.cmake │ ├── MakeBoost.cmake │ ├── MakeOpenssl.cmake │ └── MakeProtobuf.cmake ├── jni │ ├── Android.mk │ ├── Android.mk.bak │ ├── Application.mk │ ├── Apps.mk │ ├── Apps.mk.bak │ ├── Boost.mk │ ├── Include.mk │ ├── Libs.mk │ ├── Openssl.mk │ ├── Protobuf.mk │ ├── build_arm.cmd │ ├── build_arm_4.0-.cmd │ ├── build_mips.cmd │ ├── build_mips_p2v.sh │ ├── build_p2v - x.sh │ ├── build_p2v.sh │ └── sh.exe.stackdump └── msvc │ ├── msvc10 │ ├── pbi_p2p.sln │ └── pbi_p2p.suo │ ├── msvc11 │ ├── pbi_p2p.sln │ ├── pbi_p2p.v11.suo │ └── pbi_p2p.v12.suo │ ├── msvc12 │ ├── baidu_p.sln │ ├── baidu_p.v12.suo │ ├── baidu_p2p.suo │ └── suoF462.tmp │ ├── msvc8 │ └── pbi_p2p_vod.sln │ └── msvc9 │ └── pbi_p2p_vod.sln ├── clean_msvc_useless.cmd ├── contrib ├── CMakeLists.txt └── cppdb │ ├── CMakeLists.txt │ ├── cppdb.vcproj │ ├── cppdb.vcxproj │ ├── cppdb.vcxproj.user │ ├── cppdb │ ├── atomic_counter.h │ ├── backend.h │ ├── conn_manager.h │ ├── connection_specific.h │ ├── defs.h │ ├── driver_manager.h │ ├── errors.h │ ├── frontend.h │ ├── mutex.h │ ├── numeric_util.h │ ├── pool.h │ ├── ref_ptr.h │ ├── shared_object.h │ └── utils.h │ ├── drivers │ ├── mysql_backend.cpp │ ├── odbc_backend.cpp │ ├── postgres_backend.cpp │ └── sqlite3_backend.cpp │ ├── src │ ├── atomic_counter.cpp │ ├── backend.cpp │ ├── conn_manager.cpp │ ├── driver_manager.cpp │ ├── frontend.cpp │ ├── mutex.cpp │ ├── pool.cpp │ ├── shared_object.cpp │ └── utils.cpp │ └── template_header.h └── src ├── CMakeLists.txt ├── app ├── p2s_mds │ ├── CMakeLists.txt │ ├── Makefile │ ├── auth.cpp │ ├── auth.h │ ├── cmd_receiver.cpp │ ├── cmd_receiver.h │ ├── cms_acceptor.h │ ├── main.cpp │ ├── media_relay.cpp │ ├── media_relay.h │ ├── media_server.cpp │ ├── media_server.h │ ├── p2s_mds.vcproj │ ├── p2s_mds.vcxproj │ ├── p2s_mds_2.vcxproj │ ├── p2s_mds_2.vcxproj.user │ ├── progress_alive_alarm.cpp │ ├── progress_alive_alarm.h │ ├── utility.cpp │ ├── utility.h │ └── version.h ├── p2s_mds_cache │ ├── cache.h │ ├── cache_policy.h │ ├── main.cpp │ ├── mds_cache_service.cpp │ ├── mds_cache_service.h │ ├── p2s_mds_cache.vcproj │ ├── p2s_mds_cache.vcxproj │ ├── p2s_mds_cache.vcxproj.user │ └── version.h ├── p2s_mds_control │ ├── main.cpp │ ├── mds_control.cpp │ ├── mds_control.h │ ├── mds_db.db │ ├── p2s_mds_control.vcproj │ ├── p2s_mds_control.vcxproj │ ├── p2s_mds_control.vcxproj.user │ ├── utility.cpp │ ├── utility.h │ └── version.h ├── p2s_ppc │ ├── CMakeLists.txt │ ├── channel_req_processor.cpp │ ├── channel_req_processor.h │ ├── main.cpp │ ├── main_interface.cpp │ ├── main_interface.h │ ├── nat_type │ ├── p2p_processor.cpp │ ├── p2p_processor.hpp │ ├── p2s_ppc.vcproj │ ├── p2s_ppc.vcxproj │ ├── p2s_ppc.vcxproj.user │ ├── pa_handler_log.txt │ ├── parse_ams_xml.cpp │ ├── parse_ams_xml.h │ ├── request_session_ams.cpp │ ├── request_session_ams.h │ ├── request_session_base.cpp │ ├── request_session_base.h │ ├── rsa_rc4.cpp │ ├── rsa_rc4.h │ ├── server.cpp │ ├── server.hpp │ ├── typedef.h │ ├── url_crack_process.cpp │ ├── url_crack_processor.h │ ├── utility.cpp │ ├── utility.h │ ├── version.h │ ├── viewing_state_processor.cpp │ └── viewing_state_processor.h ├── p2s_shunt │ ├── alive_alarm.cpp │ ├── alive_alarm.h │ ├── main.cpp │ ├── make_proto.bat │ ├── nat_type │ ├── p2s_shunt.vcproj │ ├── p2s_shunt.vcxproj │ ├── p2s_shunt.vcxproj.user │ ├── shunt.pb.cc │ ├── shunt.pb.h │ ├── shunt.proto │ ├── shunt.xml │ └── version.h ├── p2s_shunt_control │ ├── main.cpp │ ├── p2s_shunt_control.vcproj │ ├── p2s_shunt_control.vcxproj │ ├── p2s_shunt_control.vcxproj.user │ ├── shunt_control.cpp │ ├── shunt_control.h │ └── version.h ├── p2s_tracker │ ├── main.cpp │ ├── p2s_tracker.vcproj │ ├── p2s_tracker.vcxproj │ ├── p2s_tracker.vcxproj.user │ └── version.h └── win_service │ ├── config.ini │ ├── service.cpp │ ├── service.h │ ├── version.h │ ├── win_service.vcproj │ ├── win_service.vcxproj │ ├── win_service.vcxproj.filters │ └── win_service.vcxproj.user ├── compile_settings ├── configration.props ├── configration.vsprops ├── libtorrent_upnp.vsprops ├── test_props.props └── test_props.vsprops ├── lib ├── app_common │ ├── app_common.h │ ├── app_common.vcproj │ ├── app_common.vcxproj │ ├── app_common.vcxproj.user │ ├── control_base.cpp │ ├── control_base.h │ ├── interprocess.cpp │ ├── interprocess.h │ ├── level_db.cpp │ ├── level_db.h │ ├── make.bat │ ├── mds.pb.cc │ ├── mds.pb.h │ ├── mds.proto │ ├── mds_db.cpp │ ├── mds_db.h │ ├── process_killer.cpp │ ├── process_killer.h │ ├── protoc.exe │ ├── shunt_db.cpp │ ├── shunt_db.h │ └── typedef.h ├── asfio │ ├── asfio.vcproj │ ├── asfio.vcxproj │ ├── asfio.vcxproj.user │ ├── async_dskcache.h │ ├── config.h │ ├── disk_cache_impl.cpp │ ├── disk_cache_impl.hpp │ ├── dispatch_helper.hpp │ ├── new_timeshift_io.cpp │ ├── new_timeshift_io.hpp │ ├── os_api.cpp │ └── os_api.hpp ├── client │ ├── __client │ ├── cache │ │ ├── cache_service.cpp │ │ └── cache_service.h │ ├── client.vcproj │ ├── client.vcxproj │ ├── client.vcxproj.filters │ ├── client.vcxproj.user │ ├── client_service.cpp │ ├── client_service.h │ ├── client_service_logic.cpp │ ├── client_service_logic.h │ ├── hub │ │ ├── hub_scheduling.cpp │ │ ├── hub_scheduling.h │ │ ├── hub_topology.cpp │ │ └── hub_topology.h │ ├── local_param.h │ ├── nat.cpp │ ├── nat.h │ ├── neighbor_map.cpp │ ├── neighbor_map.h │ ├── overlay.cpp │ ├── overlay.h │ ├── pa_handler.cpp │ ├── pa_handler.h │ ├── peer.cpp │ ├── peer.h │ ├── peer_connection.cpp │ ├── peer_connection.h │ ├── scheduling_base.h │ ├── stream │ │ ├── absent_packet_info.cpp │ │ ├── absent_packet_info.h │ │ ├── absent_packet_list.cpp │ │ ├── absent_packet_list.h │ │ ├── buffer_manager.cpp │ │ ├── buffer_manager.h │ │ ├── heuristic_scheduling_strategy.cpp │ │ ├── heuristic_scheduling_strategy.h │ │ ├── live_media_dispatcher.cpp │ │ ├── live_media_dispatcher.h │ │ ├── media_dispatcher.cpp │ │ ├── media_dispatcher.h │ │ ├── scheduling_typedef.cpp │ │ ├── scheduling_typedef.h │ │ ├── stream_monitor.cpp │ │ ├── stream_monitor.h │ │ ├── stream_scheduling.cpp │ │ ├── stream_scheduling.h │ │ ├── stream_seed.cpp │ │ ├── stream_seed.h │ │ ├── stream_topology.cpp │ │ ├── stream_topology.h │ │ ├── vod_media_dispatcher.cpp │ │ └── vod_media_dispatcher.h │ ├── stun │ │ ├── stun.cpp │ │ ├── stun.h │ │ ├── udp.cpp │ │ └── udp.h │ ├── tracker_manager.cpp │ ├── tracker_manager.h │ └── typedef.h ├── common │ ├── Makefile │ ├── bignumber.h │ ├── common.h │ ├── common.vcproj │ ├── common.vcxproj │ ├── common.vcxproj.filters │ ├── common.vcxproj.user │ ├── config.h │ ├── const_define.cpp │ ├── const_define.h │ ├── curve25519.cpp │ ├── curve25519.h │ ├── fec.cpp │ ├── fec.h │ ├── make.bat │ ├── make_pa_proto.bat │ ├── md5.cpp │ ├── md5.h │ ├── media_packet.h │ ├── message.pb.cc │ ├── message.pb.h │ ├── message.proto │ ├── message_type.h │ ├── pa_message.pb.cc │ ├── pa_message.pb.h │ ├── pa_message.proto │ ├── packet_buffer.cpp │ ├── packet_buffer.h │ ├── parameter.cpp │ ├── parameter.h │ ├── policy.cpp │ ├── policy.h │ ├── protoc.exe │ ├── security_policy.cpp │ ├── security_policy.h │ ├── smoother.cpp │ ├── smoother.h │ ├── tsparse.cpp │ ├── tsparse.h │ ├── typedef.h │ ├── upload_capacity_detect.cpp │ ├── upload_capacity_detector.h │ ├── utility.cpp │ └── utility.h ├── httpdownload │ ├── ReadMe.txt │ ├── http_download_base.cpp │ ├── http_download_base.hpp │ ├── http_download_file.cpp │ ├── http_download_file.hpp │ ├── http_download_memory.cpp │ ├── http_download_memory.hpp │ ├── httpdownload.vcproj │ ├── httpdownload.vcxproj │ ├── httpdownload.vcxproj.filters │ └── httpdownload.vcxproj.user ├── lib_template │ └── lib_template.vcproj ├── libupnp │ ├── buffer.hpp │ ├── device_xml_fetcher.h │ ├── error_code.hpp │ ├── escape_string.hpp │ ├── http_parser.hpp │ ├── libtorrent_upnp.vcxproj │ ├── libtorrent_upnp.vcxproj.filters │ ├── libtorrent_upnp.vcxproj.user │ ├── libupnp.vcproj │ ├── src │ │ ├── device_xml_fetcher.cpp │ │ ├── error_code.cpp │ │ ├── escape_string.cpp │ │ ├── http_parser.cpp │ │ └── upnp.cpp │ ├── upnp.hpp │ ├── utility.h │ ├── version.hpp │ └── xml_parse.hpp ├── natpunch │ ├── auto_mapping.h │ ├── natpunch.vcproj │ ├── natpunch.vcxproj │ ├── natpunch.vcxproj.user │ ├── port_mapping.h │ ├── src │ │ ├── auto_mapping.cpp │ │ └── upnp_punch.cpp │ └── upnp_punch.h ├── p2engine │ ├── CMakeList.txt │ ├── CMakeLists.txt │ ├── Makefile │ ├── p2engine-10.0.vcxproj │ ├── p2engine-9.0.vcproj │ ├── p2engine.vcproj │ ├── p2engine.vcxproj │ ├── p2engine.vcxproj.filters │ ├── p2engine.vcxproj.user │ ├── p2engine │ │ ├── acceptor.hpp │ │ ├── atomic.hpp │ │ ├── basic_dispatcher.hpp │ │ ├── basic_engine_object.hpp │ │ ├── basic_memory_pool.hpp │ │ ├── basic_object.hpp │ │ ├── basic_object_allocator.hpp │ │ ├── basic_packet.hpp │ │ ├── bool_convertable.hpp │ │ ├── broadcast_socket.hpp │ │ ├── byteorder.hpp │ │ ├── compressed_bitset.hpp │ │ ├── config.hpp │ │ ├── config │ │ │ ├── function.hpp │ │ │ └── std_or_boost.hpp │ │ ├── connection.hpp │ │ ├── contrib.hpp │ │ ├── convertutf.h │ │ ├── coroutine.hpp │ │ ├── enum_net.hpp │ │ ├── fast_stl.hpp │ │ ├── file │ │ │ ├── aiofile.hpp │ │ │ ├── basic_aiofile.hpp │ │ │ ├── basic_io_handle.hpp │ │ │ ├── file_api.hpp │ │ │ ├── file_background_service.hpp │ │ │ ├── normal_aiofile_service.hpp │ │ │ ├── posix_aiofile_service.hpp │ │ │ └── win_aiofile_service.hpp │ │ ├── fssignal.hpp │ │ ├── get_derived_this.hpp │ │ ├── gzip.hpp │ │ ├── handler_allocator.hpp │ │ ├── http │ │ │ ├── atom.hpp │ │ │ ├── basic_http_dispatcher.hpp │ │ │ ├── header.hpp │ │ │ ├── http.hpp │ │ │ ├── http_acceptor.hpp │ │ │ ├── http_acceptor_base.hpp │ │ │ ├── http_connection.hpp │ │ │ ├── http_connection_base.hpp │ │ │ ├── http_connection_impl.hpp │ │ │ ├── mime_types.hpp │ │ │ ├── request.hpp │ │ │ └── response.hpp │ │ ├── intrusive_ptr_base.hpp │ │ ├── io.hpp │ │ ├── io_service_pool.hpp │ │ ├── keeper.hpp │ │ ├── local_id_allocator.hpp │ │ ├── logging.hpp │ │ ├── macro.hpp │ │ ├── mutex.hpp │ │ ├── nedmalloc │ │ │ ├── malloc.c.h │ │ │ └── nedmalloc.h │ │ ├── ntp.hpp │ │ ├── object_allocator.hpp │ │ ├── operation_mark.hpp │ │ ├── operation_queue.hpp │ │ ├── p2engine.hpp │ │ ├── packet.hpp │ │ ├── packet_format_def.hpp │ │ ├── pop_warning_option.hpp │ │ ├── post_in_constructor.hpp │ │ ├── puff.hpp │ │ ├── push_warning_option.hpp │ │ ├── random.hpp │ │ ├── raw_buffer.hpp │ │ ├── rdp.hpp │ │ ├── rdp │ │ │ ├── basic_shared_tcp_layer.hpp │ │ │ ├── basic_shared_udp_layer.hpp │ │ │ ├── basic_urdp_visitor.hpp │ │ │ ├── const_define.hpp │ │ │ ├── rdp_fwd.hpp │ │ │ ├── trdp_acceptor.hpp │ │ │ ├── trdp_connection.hpp │ │ │ ├── trdp_flow.hpp │ │ │ ├── urdp_acceptor.hpp │ │ │ ├── urdp_connection.hpp │ │ │ ├── urdp_flow.hpp │ │ │ └── urdp_visitor.hpp │ │ ├── running_service.hpp │ │ ├── safe_buffer.hpp │ │ ├── safe_buffer_io.hpp │ │ ├── shared_access.hpp │ │ ├── singleton.hpp │ │ ├── socket_utility.hpp │ │ ├── speed_meter.hpp │ │ ├── spinlock.hpp │ │ ├── ssl_stream_wrapper.hpp │ │ ├── time.hpp │ │ ├── timer.hpp │ │ ├── trafic_statistics.hpp │ │ ├── type_traits.hpp │ │ ├── typedef.hpp │ │ ├── uri.hpp │ │ ├── utf8.hpp │ │ ├── utilities.hpp │ │ ├── variant_endpoint.hpp │ │ └── wrappable_integer.hpp │ └── src │ │ ├── basic_dispatcher.cpp │ │ ├── broadcast_socket.cpp │ │ ├── convertutf.cpp │ │ ├── enum_net.cpp │ │ ├── file │ │ └── file_api.cpp │ │ ├── gzip.cpp │ │ ├── http │ │ ├── basic_http_dispatcher.cpp │ │ ├── header.cpp │ │ ├── http_connection_impl.cpp │ │ ├── mime_types.cpp │ │ ├── request.cpp │ │ └── response.cpp │ │ ├── logging.cpp │ │ ├── nedmalloc │ │ └── nedmalloc.cpp │ │ ├── ntp.cpp │ │ ├── puff.cpp │ │ ├── rdp │ │ ├── basic_shared_tcp_layer.cpp │ │ ├── basic_shared_udp_layer.cpp │ │ ├── rdp.rar │ │ ├── trdp_flow.cpp │ │ └── urdp_flow.cpp │ │ ├── safe_buffer.cpp │ │ ├── socket_utility.cpp │ │ ├── time.cpp │ │ ├── uri.cpp │ │ └── utf8.cpp ├── server │ ├── CMakeList.txt │ ├── CMakeLists.txt │ ├── Makefile │ ├── config.h │ ├── media_distributor.cpp │ ├── media_distributor.h │ ├── seed_connection.cpp │ ├── seed_connection.h │ ├── server.vcproj │ ├── server.vcxproj │ ├── server.vcxproj.filters │ ├── server.vcxproj.user │ ├── server_service.cpp │ ├── server_service.h │ ├── server_service_logic.h │ ├── tracker_session.cpp │ └── tracker_session.h ├── shunt │ ├── config.h │ ├── creator.cpp │ ├── creator.h │ ├── fluid_media_convert.h │ ├── fluid_receiver.cpp │ ├── fluid_receiver.h │ ├── fluid_sender.cpp │ ├── fluid_sender.h │ ├── media_receiver.cpp │ ├── media_receiver.h │ ├── media_sender.cpp │ ├── media_sender.h │ ├── receiver.h │ ├── sender.h │ ├── shunt.cpp │ ├── shunt.h │ ├── shunt.vcproj │ ├── shunt.vcxproj │ ├── shunt.vcxproj.user │ ├── typedef.h │ └── vlc │ │ ├── deprecated.h │ │ ├── libvlc.h │ │ ├── libvlc_events.h │ │ ├── libvlc_media.h │ │ ├── libvlc_media_discoverer.h │ │ ├── libvlc_media_library.h │ │ ├── libvlc_media_list.h │ │ ├── libvlc_media_list_player.h │ │ ├── libvlc_media_player.h │ │ ├── libvlc_structures.h │ │ ├── libvlc_version.h.in │ │ ├── libvlc_vlm.h │ │ └── vlc.h ├── simple_server │ ├── config.h │ ├── distributor_Impl.hpp │ ├── distributor_scheduling.cpp │ ├── distributor_scheduling.h │ ├── multi_source_distributor.cpp │ ├── multi_source_distributor.h │ ├── peer_connection.cpp │ ├── peer_connection.h │ ├── simple_distributor.cpp │ ├── simple_distributor.h │ ├── simple_server.vcproj │ ├── simple_server.vcxproj │ ├── simple_server.vcxproj.user │ ├── utility.cpp │ └── utility.h ├── tracker │ ├── CMakeLists.txt │ ├── Makefile │ ├── cache_service.cpp │ ├── cache_service.h │ ├── cache_table.cpp │ ├── cache_table.h │ ├── config.h │ ├── member_service.cpp │ ├── member_service.h │ ├── member_table.cpp │ ├── member_table.h │ ├── tracker.csi │ ├── tracker.vcproj │ ├── tracker.vcxproj │ ├── tracker.vcxproj.filters │ ├── tracker.vcxproj.user │ ├── tracker_service.cpp │ ├── tracker_service.h │ ├── tracker_service_logic.cpp │ └── tracker_service_logic.h └── urlcrack │ ├── crack_letv_urls.cpp │ ├── crack_letv_urls.hpp │ ├── crack_qiyi_urls.cpp │ ├── crack_qiyi_urls.hpp │ ├── crack_qq_urls.cpp │ ├── crack_qq_urls.hpp │ ├── crack_sohu_urls.cpp │ ├── crack_sohu_urls.hpp │ ├── crack_urls_adapter.cpp │ ├── crack_urls_adapter.hpp │ ├── crack_urls_base.cpp │ ├── crack_urls_base.hpp │ ├── crack_youku_urls.cpp │ ├── crack_youku_urls.hpp │ ├── urlcrack.vcproj │ ├── urlcrack.vcxproj │ ├── urlcrack.vcxproj.filters │ └── urlcrack.vcxproj.user └── test ├── asfile_test ├── asfile_test.cpp └── asfile_test.vcproj ├── client_test ├── client_test.cpp └── client_test.vcproj ├── dht_test ├── ReadMe.txt ├── channel_list_send.cpp ├── dht_test.vcxproj ├── dht_test.vcxproj.filters ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── dht_test_1 ├── ReadMe.txt ├── channel_list_get.cpp ├── command_manager.vcxproj ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── peer_test ├── command_line_interpreter.hpp ├── peer_test.cpp ├── peer_test.vcproj └── peer_test.vcxproj ├── server_test ├── server_test.cpp └── server_test.vcproj ├── test ├── RemoveCommentary.exe ├── fssignal.cpp ├── fssignal.hpp ├── include │ ├── utf8.h │ └── utf8 │ │ ├── checked.h │ │ ├── core.h │ │ └── unchecked.h ├── server.cpp ├── server.cpp.tmp ├── tcp-fast.cpp ├── tcp-fast.h ├── test.cpp ├── test.cpp.tmp ├── test.vcproj ├── test.vcxproj ├── test.vcxproj.filters └── test.vcxproj.user ├── test_playe ├── test_player.cpp └── test_player.vcproj ├── tracker_test ├── tracker_test.cpp └── tracker_test.vcproj └── unit_test.h /README.md: -------------------------------------------------------------------------------- 1 | # P2Streaming 2 | P2Streaming is a system of streaming media content, such as videos or audio, over a peer-to-peer network. P2Streaming can support both Video on Demand (VOD) and live streaming scenarios in a Peer-to-Peer (P2P) context. In traditional client-server streaming, the content is delivered from a central server to multiple clients. In P2Streaming, the content is distributed among multiple peers (users) who simultaneously receive and relay the content to other peers. 3 | 4 | P2Streaming leverages the collective resources of the peers in the network, such as their upload bandwidth and processing power, to distribute the streaming workload. Each peer in the network acts as both a receiver and a sender of data. When a peer receives a portion of the media content, it can relay that portion to other peers who request it, reducing the strain on the central server and improving scalability. 5 | 6 | P2Streaming can provide several benefits, including: 7 | 8 | * Scalability: By distributing the streaming workload among multiple peers, P2Streaming can handle increased demand without relying solely on a central server. 9 | 10 | * Redundancy: Since the content is distributed across multiple peers, P2Streaming can provide resilience against failures or network disruptions. If one peer becomes unavailable, other peers can continue to relay the content. 11 | 12 | * Lower server bandwidth costs: With P2Streaming, the server's bandwidth requirements can be reduced since the content is shared among peers. This can be particularly advantageous for popular or bandwidth-intensive content. 13 | 14 | * Faster streaming start time: P2Streaming can enable faster start times for streaming media since the content can be retrieved from multiple sources simultaneously. 15 | 16 | The repository contains the server-side, client-side, and multi-cloud remote transmission components of the system. 17 | -------------------------------------------------------------------------------- /build/NUL_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/build/NUL_ -------------------------------------------------------------------------------- /build/android/CMakeCache.android.initial.cmake: -------------------------------------------------------------------------------- 1 | ######################## 2 | # Initial cache settings for opencv on android 3 | # run cmake with: 4 | # cmake -C 5 | ######################## 6 | 7 | #Build shared libraries (.dll/.so CACHE BOOL "" ) instead of static ones (.lib/.a CACHE BOOL "" ) 8 | set(BUILD_SHARED_LIBS OFF CACHE BOOL "" ) 9 | 10 | #Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel. 11 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" ) 12 | -------------------------------------------------------------------------------- /build/android/README.android: -------------------------------------------------------------------------------- 1 | See http://opencv.willowgarage.com/wiki/Android 2 | -------------------------------------------------------------------------------- /build/android/scripts/cmake_android.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | PUSHD %~dp0.. 4 | CALL .\scripts\build.cmd %* 5 | POPD -------------------------------------------------------------------------------- /build/android/scripts/cmake_android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0`/.. 3 | 4 | mkdir -p build 5 | cd build 6 | 7 | cmake -C ../CMakeCache.android.initial.cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. 8 | 9 | -------------------------------------------------------------------------------- /build/android/scripts/cmake_android_armeabi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0`/.. 3 | 4 | mkdir -p build_armeabi 5 | cd build_armeabi 6 | 7 | cmake -C ../CMakeCache.android.initial.cmake -DANDROID_ABI=armeabi -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. 8 | 9 | -------------------------------------------------------------------------------- /build/android/scripts/cmake_android_neon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0`/.. 3 | 4 | mkdir -p build_neon 5 | cd build_neon 6 | 7 | cmake -C ../CMakeCache.android.initial.cmake -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake $@ ../.. 8 | 9 | -------------------------------------------------------------------------------- /build/android/scripts/wincfg.cmd.tmpl: -------------------------------------------------------------------------------- 1 | :: variables required for OpenCV build :: 2 | :: Note: all pathes should be specified without tailing slashes! 3 | SET ANDROID_NDK=C:\full\path\to\your\copy\of\android\NDK\android-ndk-r7 4 | SET CMAKE_EXE=C:\full\path\to\cmake\utility\cmake.exe 5 | SET MAKE_EXE=%ANDROID_NDK%\prebuilt\windows\bin\make.exe 6 | 7 | :: variables required for android-opencv build :: 8 | SET ANDROID_SDK=C:\full\path\to\your\copy\of\android\SDK\android-sdk-windows 9 | SET ANT_DIR=C:\full\path\to\ant\directory\apache-ant-1.8.2 10 | SET JAVA_HOME=C:\full\path\to\JDK\jdk1.6.0_25 11 | 12 | :: configuration options :: 13 | :::: general ARM-V7 settings 14 | SET ANDROID_ABI=armeabi-v7a 15 | SET BUILD_DIR=build 16 | 17 | :::: uncomment following lines to compile for old emulator or old device 18 | ::SET ANDROID_ABI=armeabi 19 | ::SET BUILD_DIR=build_armeabi 20 | 21 | :::: uncomment following lines to compile for ARM-V7 with NEON support 22 | ::SET ANDROID_ABI=armeabi-v7a with NEON 23 | ::SET BUILD_DIR=build_neon 24 | 25 | :::: uncomment following lines to compile for x86 26 | ::SET ANDROID_ABI=x86 27 | ::SET BUILD_DIR=build_x86 28 | 29 | :::: other options 30 | ::SET ANDROID_NATIVE_API_LEVEL=8 &:: android-3 is enough for native part of OpenCV but android-8 is required for Java API and samples 31 | -------------------------------------------------------------------------------- /build/jni/Android.mk: -------------------------------------------------------------------------------- 1 | include $(APP_PROJECT_PATH)/Apps.mk 2 | include $(APP_PROJECT_PATH)/Libs.mk 3 | include $(APP_PROJECT_PATH)/Boost.mk 4 | include $(APP_PROJECT_PATH)/Openssl.mk 5 | include $(APP_PROJECT_PATH)/Protobuf.mk 6 | -------------------------------------------------------------------------------- /build/jni/Android.mk.bak: -------------------------------------------------------------------------------- 1 | LOCAL_EXPORT_CPPFLAGS += -ffunction-sections -fdata-sections -fvisibility=hidden -flto 2 | LOCAL_EXPORT_CFLAGS += -ffunction-sections -fdata-sections -flto 3 | ifeq ($(TARGET_ARCH),mips) 4 | LOCAL_EXPORT_LDFLAGS += -Wl,--gc-sections 5 | else 6 | LOCAL_EXPORT_LDFLAGS += -Wl,--gc-sections,--icf=safe 7 | endif 8 | 9 | include $(APP_PROJECT_PATH)/Apps.mk 10 | include $(APP_PROJECT_PATH)/Libs.mk 11 | include $(APP_PROJECT_PATH)/Boost.mk 12 | include $(APP_PROJECT_PATH)/Openssl.mk 13 | include $(APP_PROJECT_PATH)/Protobuf.mk 14 | -------------------------------------------------------------------------------- /build/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_PROJECT_PATH := $(shell pwd) 2 | 3 | APP_CPPFLAGS += -fexceptions 4 | APP_CPPFLAGS += -frtti 5 | 6 | APP_STL := gnustl_static 7 | 8 | APP_CFLAGS+=-DANDROID=1\ 9 | -D_GLIBCXX_USE_WCHAR_T=1 10 | 11 | APP_BUILD_SCRIPT := $(APP_PROJECT_PATH)/Android.mk 12 | -------------------------------------------------------------------------------- /build/jni/Apps.mk: -------------------------------------------------------------------------------- 1 | #=================================================================== 2 | #p2s_ppc 3 | #=================================================================== 4 | LOCAL_PATH:= $(call my-dir) 5 | SRC_PATH_ROOT:=$(LOCAL_PATH)/../../src 6 | 7 | include $(CLEAR_VARS) 8 | include $(APP_PROJECT_PATH)/Include.mk 9 | 10 | LOCAL_MODULE := p2s_ppc 11 | LOCAL_MODULE_TAGS := release 12 | LOCAL_FORCE_STATIC_EXECUTABLE := true 13 | 14 | #LOCAL_LDLIBS +=../obj/local/$(APP_ABI)/libgnustl_static.a 15 | 16 | LOCAL_STATIC_LIBRARIES += \ 17 | libclient \ 18 | libcommon \ 19 | simple_server\ 20 | liburlcrack\ 21 | libhttpdownload\ 22 | libasfio\ 23 | libnatpunch \ 24 | libupnp \ 25 | libp2engine \ 26 | libmessage \ 27 | \ 28 | libprotobuf\ 29 | \ 30 | libboost_filesystem\ 31 | libboost_date_time\ 32 | libboost_system\ 33 | libboost_program_options\ 34 | libboost_thread\ 35 | libboost_regex\ 36 | \ 37 | libssl\ 38 | libcrypto\ 39 | \ 40 | libgnustl_static\ 41 | 42 | 43 | LOCAL_LDFLAGS += \ 44 | 45 | 46 | #find all c files in source dir 47 | local_src_files := $(wildcard $(SRC_PATH_ROOT)/app/p2s_ppc/*.cpp) 48 | 49 | #remove parent path of all c files in source dir 50 | local_src_files := $(local_src_files:$(LOCAL_PATH)/%=%) 51 | 52 | LOCAL_SRC_FILES := $(local_src_files) 53 | 54 | include $(BUILD_EXECUTABLE) 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /build/jni/Apps.mk.bak: -------------------------------------------------------------------------------- 1 | #=================================================================== 2 | #p2s_ppc 3 | #=================================================================== 4 | LOCAL_PATH:= $(call my-dir) 5 | SRC_PATH_ROOT:=$(LOCAL_PATH)/../../src 6 | 7 | include $(CLEAR_VARS) 8 | include $(APP_PROJECT_PATH)/Include.mk 9 | 10 | LOCAL_MODULE := p2s_ppc 11 | LOCAL_MODULE_TAGS := release 12 | LOCAL_FORCE_STATIC_EXECUTABLE := true 13 | 14 | #LOCAL_LDLIBS +=../obj/local/$(APP_ABI)/libgnustl_static.a 15 | 16 | LOCAL_STATIC_LIBRARIES += \ 17 | libclient \ 18 | libcommon \ 19 | simple_server\ 20 | liburlcrack\ 21 | libhttpdownload\ 22 | libasfio\ 23 | libnatpunch \ 24 | libupnp \ 25 | libp2engine \ 26 | libmessage \ 27 | \ 28 | libprotobuf\ 29 | \ 30 | libboost_filesystem\ 31 | libboost_date_time\ 32 | libboost_system\ 33 | libboost_program_options\ 34 | libboost_thread\ 35 | libboost_regex\ 36 | \ 37 | libssl\ 38 | libcrypto\ 39 | \ 40 | libgnustl_static\ 41 | 42 | 43 | LOCAL_LDFLAGS += \ 44 | 45 | 46 | #find all c files in source dir 47 | local_src_files := $(wildcard $(SRC_PATH_ROOT)/app/p2s_ppc/*.cpp) 48 | 49 | #remove parent path of all c files in source dir 50 | local_src_files := $(local_src_files:$(LOCAL_PATH)/%=%) 51 | 52 | LOCAL_SRC_FILES := $(local_src_files) 53 | 54 | 55 | include $(BUILD_EXECUTABLE) 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /build/jni/Include.mk: -------------------------------------------------------------------------------- 1 | LOCAL_CPP_FEATURES += exceptions 2 | 3 | LOCAL_C_INCLUDES += \ 4 | $(APP_PROJECT_PATH)/../../src/lib \ 5 | $(APP_PROJECT_PATH)/../../src/lib/p2engine \ 6 | $(APP_PROJECT_PATH)/../../src/app \ 7 | \ 8 | $(BOOST_PATH) \ 9 | $(OPENSSL_PATH)/include \ 10 | $(PROTOBUF_PATH)/include \ 11 | $(ANDROID_NDK)/sources/cxx-stl/gnu-libstdc++/include\ 12 | -------------------------------------------------------------------------------- /build/jni/Openssl.mk: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | #openssl libs 3 | #################################################################### 4 | include $(OPENSSL_PATH)/Android.mk 5 | -------------------------------------------------------------------------------- /build/jni/Protobuf.mk: -------------------------------------------------------------------------------- 1 | #################################################################### 2 | #openssl libs 3 | #################################################################### 4 | 5 | include $(PROTOBUF_PATH)/Android.mk 6 | -------------------------------------------------------------------------------- /build/jni/build_arm.cmd: -------------------------------------------------------------------------------- 1 | set PATH_ORG=%PATH% 2 | 3 | set BOOST_PATH=D:/lib/boost 4 | set OPENSSL_PATH=D:/lib/openssl 5 | 6 | set PROTOBUF_PATH=D:/lib/protobuf 7 | set JEMALLOC_PATH=D:/lib/jemalloc-3.0.0 8 | 9 | set ANDROID_NDK=D:/dev/android-ndk/android-ndk-r8b 10 | set NDK_ROOT=%ANDROID_NDK% 11 | set PATH=%NDK_ROOT%;%PATH_ORG% 12 | 13 | cd D:/dev/p2v/trunk/build/jni/ 14 | 15 | call %NDK_ROOT%/ndk-build.cmd -j3 APP_ABI=armeabi TARGET_PLATFORM='android-14' NDK_PROJECT_PATH=./.. APP_PROJECT_PATH:=. 16 | 17 | PAUSE 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /build/jni/build_arm_4.0-.cmd: -------------------------------------------------------------------------------- 1 | set PATH_ORG=%PATH% 2 | 3 | set BOOST_PATH=D:/lib/boost 4 | set OPENSSL_PATH=D:/lib/openssl_android 5 | 6 | set PROTOBUF_PATH=D:/lib/protobuf 7 | 8 | set ANDROID_NDK=D:/dev/android-ndk/android-ndk-r9d 9 | set NDK_ROOT=%ANDROID_NDK% 10 | set PATH=%NDK_ROOT%;%PATH_ORG% 11 | 12 | set ROOT_JNI_PATH=D:/dev/p2v/trunk/build/jni/ 13 | cd %ROOT_JNI_PATH%; 14 | 15 | call %NDK_ROOT%/ndk-build.cmd -j3 NDK_DEBUG=0 APP_ABI:=armeabi TARGET_PLATFORM='android-8' NDK_PROJECT_PATH=./.. APP_PROJECT_PATH:=. 16 | 17 | PAUSE 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /build/jni/build_mips.cmd: -------------------------------------------------------------------------------- 1 | set PATH_ORG=%PATH% 2 | 3 | set BOOST_PATH=D:/lib/boost 4 | set OPENSSL_PATH=D:/lib/openssl 5 | set PROTOBUF_PATH=D:/lib/protobuf 6 | set JEMALLOC_PATH=D:/lib/jemalloc-3.0.0 7 | 8 | set ANDROID_NDK=D:/dev/android-ndk/android-ndk-r8b 9 | set NDK_ROOT=%ANDROID_NDK% 10 | set PATH=%NDK_ROOT%;%PATH_ORG% 11 | 12 | cd D:/dev/p2v/trunk/build/jni/ 13 | 14 | call %NDK_ROOT%/ndk-build.cmd -j3 APP_ABI=mips TARGET_PLATFORM='android-8' NDK_PROJECT_PATH=./.. APP_PROJECT_PATH:=. 15 | 16 | PAUSE 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /build/jni/build_mips_p2v.sh: -------------------------------------------------------------------------------- 1 | export ANDROID_NDK="/cygdrive/d/dev/android-ndk/android-ndk-r7m" 2 | export NDK_ROOT=$ANDROID_NDK 3 | 4 | export PATH="$NDK_ROOT:$PATH_ORG" 5 | 6 | cd /cygdrive/d/dev/p2v/trunk/build/jni/ 7 | ndk-build -j4 HOST_AWK=gawk APP_ABI=mips APP_TOOLCHAIN_VERSION='4.4.3' NDK_PROJECT_PATH=../ 8 | -------------------------------------------------------------------------------- /build/jni/build_p2v - x.sh: -------------------------------------------------------------------------------- 1 | export ANDROID_NDK="D:/android-ndk-r9d" 2 | export NDK_ROOT=$ANDROID_NDK 3 | 4 | export PATH="$NDK_ROOT:$PATH_ORG" 5 | 6 | cd D:/project/p2v/trunk/build/jni 7 | ndk-build clean 8 | ndk-build -j4 HOST_AWK=gawk APP_ABI=armeabi APP_TOOLCHAIN_VERSION='4.4.3' NDK_PROJECT_PATH=../ 9 | -------------------------------------------------------------------------------- /build/jni/build_p2v.sh: -------------------------------------------------------------------------------- 1 | export ANDROID_NDK="/cygdrive/d/dev/android-ndk/android-ndk-r7m" 2 | export NDK_ROOT=$ANDROID_NDK 3 | 4 | export PATH="$NDK_ROOT:$PATH_ORG" 5 | 6 | cd /cygdrive/d/dev/p2v/trunk/build/jni/ 7 | ndk-build clean 8 | ndk-build -j4 HOST_AWK=gawk APP_ABI=armeabi APP_TOOLCHAIN_VERSION='4.4.3' NDK_PROJECT_PATH=../ 9 | -------------------------------------------------------------------------------- /build/jni/sh.exe.stackdump: -------------------------------------------------------------------------------- 1 | Exception: STATUS_ACCESS_VIOLATION at eip=6102048B 2 | eax=00AF07E8 ebx=61245934 ecx=76730F81 edx=002D51F8 esi=00000000 edi=0028F9F4 3 | ebp=61020C00 esp=0028C7C4 program=D:\cygwin\bin\sh.exe, pid 6464, thread main 4 | cs=0023 ds=002B es=002B fs=0053 gs=002B ss=002B 5 | Stack trace: 6 | Frame Function Args 7 | End of stack trace 8 | -------------------------------------------------------------------------------- /build/msvc/msvc10/pbi_p2p.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/build/msvc/msvc10/pbi_p2p.suo -------------------------------------------------------------------------------- /build/msvc/msvc11/pbi_p2p.v11.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/build/msvc/msvc11/pbi_p2p.v11.suo -------------------------------------------------------------------------------- /build/msvc/msvc11/pbi_p2p.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/build/msvc/msvc11/pbi_p2p.v12.suo -------------------------------------------------------------------------------- /build/msvc/msvc12/baidu_p.v12.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/build/msvc/msvc12/baidu_p.v12.suo -------------------------------------------------------------------------------- /build/msvc/msvc12/baidu_p2p.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/build/msvc/msvc12/baidu_p2p.suo -------------------------------------------------------------------------------- /build/msvc/msvc12/suoF462.tmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/build/msvc/msvc12/suoF462.tmp -------------------------------------------------------------------------------- /clean_msvc_useless.cmd: -------------------------------------------------------------------------------- 1 | del *.ncb /F /Q /S 2 | del *.ipch /F /Q /S 3 | del *.sdf /F /Q /S 4 | -------------------------------------------------------------------------------- /contrib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /contrib/cppdb/cppdb.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /contrib/cppdb/cppdb/connection_specific.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2010-2011 Artyom Beilis (Tonkikh) 4 | // 5 | // Distributed under: 6 | // 7 | // the Boost Software License, Version 1.0. 8 | // (See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // or (at your opinion) under: 12 | // 13 | // The MIT License 14 | // (See accompanying file MIT.txt or a copy at 15 | // http://www.opensource.org/licenses/mit-license.php) 16 | // 17 | /////////////////////////////////////////////////////////////////////////////// 18 | #ifndef CPPDB_CONNECTION_SPECIFIC_H 19 | #define CPPDB_CONNECTION_SPECIFIC_H 20 | 21 | #include 22 | #include 23 | 24 | namespace cppdb { 25 | /// 26 | /// \brief Special abstract object that holds a connection specific data 27 | /// 28 | /// The user is expected to derive its own object from this class 29 | /// and save them withing the connection 30 | /// 31 | class CPPDB_API connection_specific_data { 32 | connection_specific_data(connection_specific_data const &); 33 | void operator=(connection_specific_data const &); 34 | public: 35 | connection_specific_data(); 36 | virtual ~connection_specific_data(); 37 | 38 | private: 39 | struct data; 40 | std::auto_ptr d; 41 | }; 42 | 43 | 44 | } // cppdb 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /contrib/cppdb/cppdb/defs.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2010-2011 Artyom Beilis (Tonkikh) 4 | // 5 | // Distributed under: 6 | // 7 | // the Boost Software License, Version 1.0. 8 | // (See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // or (at your opinion) under: 12 | // 13 | // The MIT License 14 | // (See accompanying file MIT.txt or a copy at 15 | // http://www.opensource.org/licenses/mit-license.php) 16 | // 17 | /////////////////////////////////////////////////////////////////////////////// 18 | #ifndef CPPDB_DEFS_H 19 | #define CPPDB_DEFS_H 20 | 21 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__CYGWIN__) 22 | # if defined(DLL_EXPORT) || defined(CPPDB_EXPORTS) || defined(CPPDB_DRIVER_EXPORTS) 23 | # ifdef CPPDB_SOURCE 24 | # define CPPDB_API __declspec(dllexport) 25 | # else 26 | # define CPPDB_API __declspec(dllimport) 27 | # endif 28 | # endif 29 | # if defined(DLL_EXPORT) || defined(CPPDB_DRIVER_EXPORTS) 30 | # ifdef CPPDB_DRIVER_SOURCE 31 | # define CPPDB_DRIVER_API __declspec(dllexport) 32 | # else 33 | # define CPPDB_DRIVER_API __declspec(dllimport) 34 | # endif 35 | # endif 36 | #endif 37 | 38 | 39 | #ifndef CPPDB_API 40 | # define CPPDB_API 41 | #endif 42 | 43 | #ifndef CPPDB_DRIVER_API 44 | # define CPPDB_DRIVER_API 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /contrib/cppdb/cppdb/mutex.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2010-2011 Artyom Beilis (Tonkikh) 4 | // 5 | // Distributed under: 6 | // 7 | // the Boost Software License, Version 1.0. 8 | // (See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // or (at your opinion) under: 12 | // 13 | // The MIT License 14 | // (See accompanying file MIT.txt or a copy at 15 | // http://www.opensource.org/licenses/mit-license.php) 16 | // 17 | /////////////////////////////////////////////////////////////////////////////// 18 | #ifndef CPPDB_MUTEX_H 19 | #define CPPDB_MUTEX_H 20 | 21 | #include 22 | 23 | namespace cppdb { 24 | 25 | /// 26 | /// \brief mutex class, used internally 27 | /// 28 | class CPPDB_API mutex { 29 | mutex(mutex const &); 30 | void operator=(mutex const &); 31 | public: 32 | class guard; 33 | /// Create mutex 34 | mutex(); 35 | /// Destroy mutex 36 | ~mutex(); 37 | /// Lock mutex 38 | void lock(); 39 | /// Unlock mutex 40 | void unlock(); 41 | private: 42 | void *mutex_impl_; 43 | }; 44 | 45 | /// 46 | /// \brief scoped guard for mutex 47 | /// 48 | class mutex::guard { 49 | guard(guard const &); 50 | void operator=(guard const &); 51 | public: 52 | /// Create scoped lock 53 | guard(mutex &m) : m_(&m) 54 | { 55 | m_->lock(); 56 | } 57 | /// unlock the mutex 58 | ~guard() 59 | { 60 | m_->unlock(); 61 | } 62 | private: 63 | mutex *m_; 64 | }; 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /contrib/cppdb/template_header.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (C) 2010-2011 Artyom Beilis (Tonkikh) 4 | // 5 | // Distributed under: 6 | // 7 | // the Boost Software License, Version 1.0. 8 | // (See accompanying file LICENSE_1_0.txt or copy at 9 | // http://www.boost.org/LICENSE_1_0.txt) 10 | // 11 | // or (at your opinion) under: 12 | // 13 | // The MIT License 14 | // (See accompanying file MIT.txt or a copy at 15 | // http://www.opensource.org/licenses/mit-license.php) 16 | // 17 | /////////////////////////////////////////////////////////////////////////////// 18 | 19 | -------------------------------------------------------------------------------- /src/app/p2s_mds/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | include_directories(include) 3 | make_executable(p2s_mds) 4 | 5 | ##detail config for p2s_mds 6 | add_dependencies(p2s_mds miniupnpc) 7 | add_dependencies(p2s_mds p2engine) 8 | add_dependencies(p2s_mds natpunch) 9 | add_dependencies(p2s_mds common) 10 | add_dependencies(p2s_mds client) 11 | add_dependencies(p2s_mds tracker) 12 | add_dependencies(p2s_mds server) 13 | add_dependencies(p2s_mds interface) 14 | add_dependencies(p2s_mds service_logic) 15 | 16 | 17 | target_link_libraries(p2s_mds interface) 18 | target_link_libraries(p2s_mds service_logic) 19 | target_link_libraries(p2s_mds client) 20 | target_link_libraries(p2s_mds server) 21 | target_link_libraries(p2s_mds tracker) 22 | target_link_libraries(p2s_mds natpunch) 23 | target_link_libraries(p2s_mds common) 24 | target_link_libraries(p2s_mds p2engine) 25 | target_link_libraries(p2s_mds miniupnpc) 26 | link_boost(p2s_mds 27 | boost_system 28 | boost_regex 29 | boost_thread 30 | boost_date_time 31 | boost_filesystem 32 | ) 33 | link_protobuf(p2s_mds) 34 | 35 | set_target_properties(p2s_mds PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PREFIX}/bin) 36 | #set_target_properties(p2s_mds PROPERTIES LINK_FLAGS "-static -s -pthread -lrt -fcommon -MMD -MP -MF -Wno-deprecated") 37 | 38 | #if(${PLATFORM} STREQUAL "windows") 39 | # LINK_THIRD_PARTY_LIBS(p2s_mds Rpcrt4) 40 | #elseif(${PLATFORM} STREQUAL "linux") 41 | # LINK_THIRD_PARTY_LIBS(p2s_mds pthread rt) 42 | #endif() 43 | -------------------------------------------------------------------------------- /src/app/p2s_mds/auth.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMMON_AUTH 2 | #define __COMMON_AUTH 3 | 4 | #include "p2s_mds/media_server.h" 5 | #include 6 | #include 7 | #include 8 | 9 | using namespace p2engine; 10 | 11 | class auth 12 | :public basic_engine_object 13 | { 14 | typedef auth this_type; 15 | typedef http::http_connection http_connection; 16 | typedef boost::function on_message_handler; 17 | SHARED_ACCESS_DECLARE; 18 | 19 | protected: 20 | auth(io_service& ios); 21 | ~auth(); 22 | 23 | public: 24 | static shared_ptr create(io_service& ios) 25 | { 26 | return shared_ptr(new this_type(ios), 27 | shared_access_destroy() 28 | ); 29 | } 30 | void reset_regist_code(const std::string& regist_code) 31 | { 32 | regist_code_=regist_code; 33 | } 34 | void run(const std::string& regist_code); 35 | void stop(); 36 | on_message_handler& on_error_signal(){return on_error_signal_;} 37 | on_message_handler& on_auth_signal(){return on_auth_signal_;} 38 | 39 | protected: 40 | void on_timer(); 41 | void do_auth(const http::response& resp=http::response(), 42 | const safe_buffer& buf=safe_buffer(), 43 | error_code ec=error_code(), coroutine=coroutine() 44 | ); 45 | private: 46 | void handle_error(const std::string& errorMsg); 47 | protected: 48 | boost::shared_ptr timer_; 49 | 50 | //����֤�������Ľ��� 51 | boost::shared_ptr auth_conn_; 52 | boost::int64_t auth_content_len_; 53 | std::string auth_content_; 54 | std::pair auth_key_pair_; 55 | int auth_failed_cnt_; 56 | std::string challenge_; 57 | 58 | std::string regist_code_; 59 | on_message_handler on_error_signal_; 60 | on_message_handler on_auth_signal_; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/app/p2s_mds/media_relay.h: -------------------------------------------------------------------------------- 1 | #ifndef _MDS_MEDIA_SENDER_H__ 2 | #define _MDS_MEDIA_SENDER_H__ 3 | 4 | #include 5 | #include 6 | 7 | using namespace p2engine; 8 | 9 | class media_relay 10 | :public p2engine::basic_engine_object 11 | { 12 | typedef media_relay this_type; 13 | SHARED_ACCESS_DECLARE; 14 | 15 | typedef boost::asio::ip::tcp tcp; 16 | typedef http::basic_http_connection connection_type; 17 | typedef http::basic_http_acceptor http_acceptor; 18 | typedef boost::shared_ptr connection_sptr; 19 | 20 | protected: 21 | media_relay(io_service& ios, int listenPort); 22 | virtual ~media_relay(); 23 | 24 | public: 25 | static shared_ptr create(io_service& ios, int listenPort) 26 | { 27 | return shared_ptr(new this_type(ios, listenPort), 28 | shared_access_destroy()); 29 | } 30 | 31 | void handle_media(const safe_buffer& buf); 32 | 33 | protected: 34 | /// Perform work associated with the server. 35 | void on_accept(connection_sptr conn, error_code ec); 36 | 37 | void on_request(const http::request& req, connection_type* conn); 38 | 39 | void on_disconnected(connection_type* conn); 40 | 41 | void on_data(safe_buffer); 42 | private: 43 | boost::shared_ptr acceptor_; 44 | std::maphttp_connections_; 45 | timed_keeper_set http_connections_keeper_; 46 | }; 47 | 48 | #endif // _MDS_MEDIA_SENDER_H__ 49 | -------------------------------------------------------------------------------- /src/app/p2s_mds/media_server.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2S_MDS 2 | #define __P2S_MDS 3 | 4 | #include "common/common.h" 5 | #include "p2s_mds/media_relay.h" 6 | #include "server/server_service_logic.h" 7 | #include "tracker/tracker_service_logic.h" 8 | #include "shunt/receiver.h" 9 | 10 | using namespace p2engine; 11 | using namespace p2server; 12 | using namespace p2shunt; 13 | 14 | //������������������VLC����������������ݺ�ַ� 15 | class p2s_mds 16 | :public server_service_logic_base 17 | { 18 | typedef p2s_mds this_type; 19 | SHARED_ACCESS_DECLARE; 20 | 21 | public: 22 | static shared_ptr create(io_service& ios, 23 | const server_param_base& param, 24 | const std::string& fluidistorUrl 25 | ) 26 | { 27 | return shared_ptr(new this_type(ios, param, fluidistorUrl), 28 | shared_access_destroy() 29 | ); 30 | } 31 | 32 | void start(error_code& ec); 33 | void reset(error_code& ec); 34 | void stop(error_code& ec); 35 | 36 | protected: 37 | p2s_mds(io_service& ios, 38 | const server_param_base& param, 39 | const std::string& fluidistorUrl 40 | ); 41 | virtual ~p2s_mds(); 42 | 43 | private: 44 | bool open_distributor(const server_param_base& param); 45 | void handle_media(const safe_buffer& buf); 46 | 47 | private: 48 | std::string fluidistor_url_; 49 | 50 | //boost::shared_ptr media_relay_; 51 | 52 | boost::shared_ptr receiver_; 53 | 54 | udp::endpoint multicast_endpoint_; 55 | boost::scoped_ptr multicast_socket_; 56 | 57 | server_param_base param_; 58 | }; 59 | 60 | #endif//__P2S_MDS 61 | -------------------------------------------------------------------------------- /src/app/p2s_mds/p2s_mds.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/app/p2s_mds/p2s_mds.vcproj -------------------------------------------------------------------------------- /src/app/p2s_mds/p2s_mds_2.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/p2s_mds/progress_alive_alarm.h: -------------------------------------------------------------------------------- 1 | #ifndef MDS_PROGRESS_ALIVE_ALARM_H__ 2 | #define MDS_PROGRESS_ALIVE_ALARM_H__ 3 | 4 | #include "p2s_mds/media_server.h" 5 | #include 6 | #include 7 | #include 8 | 9 | namespace p2control{ 10 | class interprocess_client; 11 | } 12 | 13 | using namespace p2engine; 14 | using namespace p2control; 15 | 16 | class progress_alive_alarm 17 | :public basic_engine_object 18 | { 19 | typedef progress_alive_alarm this_type; 20 | typedef http::http_connection http_connection; 21 | typedef boost::function on_alarm_handler; 22 | SHARED_ACCESS_DECLARE; 23 | 24 | protected: 25 | progress_alive_alarm(boost::shared_ptr s, 26 | const time_duration& interval, const std::string& id, int type, int guardPort 27 | ); 28 | ~progress_alive_alarm(); 29 | 30 | public: 31 | static shared_ptr create(boost::shared_ptr s 32 | , const time_duration& interval, const std::string& id, int type, int guardPort 33 | ) 34 | { 35 | return shared_ptr(new this_type(s, interval, id, type, guardPort), 36 | shared_access_destroy() 37 | ); 38 | } 39 | void reset_alarm_port(int port); 40 | void start(boost::shared_ptr, error_code& ec); 41 | void stop(); 42 | void reset(error_code& ec); 43 | bool is_stoped()const{return !timer_;} 44 | 45 | protected: 46 | void on_timer(); 47 | void on_quality_reported(const safe_buffer& buf); 48 | 49 | protected: 50 | boost::shared_ptr timer_; 51 | 52 | //���ؽ��̵�http���� 53 | udp::socket guard_socket_; 54 | udp::endpoint guard_remote_edp_; 55 | 56 | std::string id_; 57 | int type_; 58 | boost::shared_ptr server_; 59 | boost::weak_ptr interprocess_client_; 60 | 61 | int interval_; 62 | ptime last_alarm_time_; 63 | }; 64 | 65 | #endif//MDS_PROGRESS_ALIVE_ALARM_H__ 66 | 67 | -------------------------------------------------------------------------------- /src/app/p2s_mds/utility.cpp: -------------------------------------------------------------------------------- 1 | #include "p2s_mds/auth.h" 2 | #include "p2s_mds/media_server.h" 3 | #include "p2s_mds/utility.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | const std::string server_key = "server"; 16 | const std::string server_id_key = "id"; 17 | const std::string server_prop_key = "prop"; 18 | const std::string channel_count_key = "count"; 19 | 20 | const std::string channel_key = "channel"; 21 | const std::string channel_id_key = "uuid"; 22 | const std::string channel_name_key = "name"; 23 | const std::string channel_prop_key = "prop"; 24 | 25 | const std::string channel_type_key = "type"; 26 | const std::string channel_path_key = "path"; 27 | const std::string channel_stream_recv_url_key = "stream_recv_url"; 28 | const std::string channel_in_addr_key = "internal_address"; 29 | const std::string channel_ex_addr_key = "external_address"; 30 | const std::string channel_tracker_addr_key = "tracker_address"; 31 | const std::string channel_key_key = "channel_key"; 32 | const std::string channel_link_key = "channel_link"; 33 | 34 | const std::string channel_duration_key = "duration"; 35 | const std::string channel_length_key = "length"; 36 | 37 | using boost::property_tree::ptree; 38 | namespace utility{ 39 | 40 | //bind port 0 41 | std::string zero_port(const std::string& ipport) 42 | { 43 | std::string::size_type pos=ipport.find(':'); 44 | if (pos==std::string::npos) 45 | return ipport + ":0"; 46 | return ipport.substr(0, pos) + ":0"; 47 | } 48 | }; -------------------------------------------------------------------------------- /src/app/p2s_mds/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef p2s_mds_utility_h__ 2 | #define p2s_mds_utility_h__ 3 | 4 | #include "p2s_mds/auth.h" 5 | #include "p2s_mds/progress_alive_alarm.h" 6 | #include "p2s_mds/media_server.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace utility{ 18 | using boost::property_tree::ptree; 19 | typedef std::vector channel_vec_type; 20 | 21 | typedef boost::unordered_map > server_map; 22 | typedef boost::unordered_map > alarm_map; 23 | typedef boost::unordered_map channel_alive_map; 24 | typedef channel_alive_map::value_type alive_value_type; 25 | typedef server_map::value_type server_value_type; 26 | typedef alarm_map::value_type alarm_value_type; 27 | 28 | std::string zero_port(const std::string& ipport);//bind port 0 29 | }; 30 | 31 | #endif // utility_h__ 32 | -------------------------------------------------------------------------------- /src/app/p2s_mds/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2S_MDS_VERSION 2 | #define __P2S_MDS_VERSION 3 | 4 | #define P2S_MDS_VERSION "2.0.0 Beta" 5 | 6 | #endif//__P2S_MDS_VERSION 7 | -------------------------------------------------------------------------------- /src/app/p2s_mds_cache/p2s_mds_cache.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/p2s_mds_cache/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2S_MDS_CACHE_VERSION 2 | #define __P2S_MDS_CACHE_VERSION 3 | 4 | #define P2S_MDS_CACHE_VERSION "2.0.0" 5 | 6 | #endif//__P2S_TRACKER_VERSION 7 | -------------------------------------------------------------------------------- /src/app/p2s_mds_control/mds_db.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/app/p2s_mds_control/mds_db.db -------------------------------------------------------------------------------- /src/app/p2s_mds_control/p2s_mds_control.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/app/p2s_mds_control/p2s_mds_control.vcproj -------------------------------------------------------------------------------- /src/app/p2s_mds_control/p2s_mds_control.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/p2s_mds_control/utility.cpp: -------------------------------------------------------------------------------- 1 | #include "p2s_mds_control/utility.h" 2 | #include 3 | 4 | namespace utility{ 5 | node_map_type hash_node_map(const int& max_process, channel_vec_type& channels) 6 | { 7 | int port_sum=0; 8 | node_map_type server_node_map; 9 | for (size_t i=0; i 3 | 4 | int main(int argc, char* argv[]) 5 | { 6 | return start_service(argc, argv); 7 | } 8 | 9 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/main_interface.h: -------------------------------------------------------------------------------- 1 | #ifndef P2S_PPC_MAIN_INTERFACE_H__ 2 | #define P2S_PPC_MAIN_INTERFACE_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /************************************************************************/ 9 | //�������� 10 | //�����в���: --help ��ӡhelp 11 | // --port=port ָ��http������ַ��Ĭ��Ϊ9906 12 | // --delay=ms ����delay��Ĭ��Ϊ3500 13 | /************************************************************************/ 14 | int start_service(int argc, char* argv[]); 15 | 16 | 17 | /************************************************************************/ 18 | //�رշ��� 19 | /************************************************************************/ 20 | int stop_service(void); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif//P2S_PPC_MAIN_INTERFACE_H__ 27 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/nat_type: -------------------------------------------------------------------------------- 1 | type=5 2 | timestamp=1406712708 3 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/p2s_ppc.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | WindowsLocalDebugger 7 | 8 | 9 | false 10 | 11 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/pa_handler_log.txt: -------------------------------------------------------------------------------- 1 | >>>>> pa_handler on create P2S pas_host: analytics.iptv168.com:10000 2 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/parse_ams_xml.cpp: -------------------------------------------------------------------------------- 1 | #include "p2s_ppc/parse_ams_xml.h" 2 | #include "p2engine/p2engine/macro.hpp" 3 | #include 4 | #include 5 | 6 | NAMESPACE_BEGIN(ppc) 7 | parse_ca_xml::parse_ca_xml(const std::string& str_xml_content) 8 | :b_parsed_(false), 9 | xml_content_(str_xml_content) 10 | { 11 | init_parse_xml(); 12 | } 13 | 14 | void parse_ca_xml::init_parse_xml() 15 | { 16 | BOOST_ASSERT(!b_parsed_); 17 | 18 | std::stringstream strstream(xml_content_); 19 | try{ 20 | typedef boost::property_tree::ptree ptree; 21 | ptree pt; 22 | boost::property_tree::xml_parser::read_xml(strstream, pt); 23 | ptree server_node = pt.get_child("xml.servers"); 24 | 25 | BOOST_FOREACH(ptree::value_type &v, server_node){ 26 | cms_server_info tem_server; 27 | tem_server.server_id_ = v.second.get_child("id").get_value(); 28 | tem_server.server_type_ = v.second.get_child("type").get_value(); 29 | tem_server.server_address_ = v.second.get_child("address").get_value(); 30 | tem_server.server_ca = v.second.get_child("ca").get_value(); 31 | servers_.push_back(tem_server); 32 | } 33 | }catch(...){} 34 | 35 | 36 | b_parsed_ = true; 37 | } 38 | 39 | void parse_ca_xml::content_reset(const std::string& str_xml_content) 40 | { 41 | b_parsed_ = false; 42 | xml_content_ = str_xml_content; 43 | servers_.clear(); 44 | 45 | init_parse_xml(); 46 | } 47 | NAMESPACE_END(ppc); -------------------------------------------------------------------------------- /src/app/p2s_ppc/parse_ams_xml.h: -------------------------------------------------------------------------------- 1 | #ifndef _PASE_AMS_XML_H_ 2 | #define _PASE_AMS_XML_H_ 3 | #include "p2s_ppc/typedef.h" 4 | #include 5 | #include 6 | namespace ppc{ 7 | struct cms_server_info{ 8 | int server_id_; 9 | int server_type_; 10 | std::string server_address_; 11 | std::string server_ca; 12 | }; 13 | 14 | class parse_ca_xml{ 15 | typedef parse_ca_xml this_type; 16 | SHARED_ACCESS_DECLARE; 17 | public: 18 | static shared_ptr create(const std::string& str_xml_content) 19 | { 20 | return shared_ptr(new parse_ca_xml(str_xml_content), 21 | shared_access_destroy()); 22 | } 23 | protected: 24 | parse_ca_xml(const std::string& str_xml_content); 25 | ~parse_ca_xml(){} 26 | public: 27 | void content_reset(const std::string& str_xml_content); 28 | public: 29 | int server_count(){ 30 | BOOST_ASSERT(b_parsed_); 31 | return servers_.size(); 32 | } 33 | 34 | cms_server_info& get_server(const int index){ 35 | BOOST_ASSERT(index>=0 && index servers_; 44 | }; 45 | 46 | } 47 | #endif //_PASE_AMS_XML_H_ -------------------------------------------------------------------------------- /src/app/p2s_ppc/rsa_rc4.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/app/p2s_ppc/rsa_rc4.cpp -------------------------------------------------------------------------------- /src/app/p2s_ppc/rsa_rc4.h: -------------------------------------------------------------------------------- 1 | #ifndef _PPC_RSA_RC4_ 2 | #define _PPC_RSA_RC4_ 3 | 4 | #include "p2engine/safe_buffer.hpp" 5 | #include 6 | 7 | namespace ppc{ 8 | using namespace p2engine; 9 | 10 | struct rc4{ 11 | enum{SIZE_TGA=4}; 12 | enum{KEY_SIZE=256}; 13 | 14 | /*KSA*/ 15 | void rc4_init(unsigned char* key, int32_t key_length); 16 | 17 | void rc4_crypt(char *Data, unsigned long Len){ 18 | rc4_crypt(seed_, KEY_SIZE, Data, Len); 19 | } 20 | 21 | void rc4_decrypt(char *Data, unsigned long Len){ 22 | rc4_decrypt(seed_, KEY_SIZE, Data, Len); 23 | } 24 | 25 | static void rc4_crypt(const unsigned char s[KEY_SIZE], unsigned long key_len, 26 | char *Data, unsigned long Len); 27 | 28 | static void rc4_decrypt(const unsigned char s[KEY_SIZE], unsigned long key_len, 29 | char *Data, unsigned long Len); 30 | 31 | private: 32 | unsigned char seed_[KEY_SIZE]; 33 | }; 34 | 35 | bool evp_decrypt(const RSA* const rsa_key, const char* encrypt_data, int encrypt_data_len, 36 | const char* ek, int ek_len, safe_buffer& result); 37 | 38 | safe_buffer get_decrypt_data(const std::string& data_content, const RSA* const rsa_key); 39 | 40 | } 41 | #endif //_PPC_RSA_RC4_ 42 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/typedef.h: -------------------------------------------------------------------------------- 1 | #ifndef p2sppc_typedef_h__ 2 | #define p2sppc_typedef_h__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "common/common.h" 12 | #include "client/client_service_logic.h" 13 | 14 | namespace ppc{ 15 | using namespace p2engine; 16 | using namespace p2client; 17 | 18 | typedef http::basic_http_connection http_connection; 19 | typedef http::basic_http_acceptor http_acceptor; 20 | } 21 | 22 | 23 | 24 | #endif //p2sppc_typedef_h__ -------------------------------------------------------------------------------- /src/app/p2s_ppc/url_crack_processor.h: -------------------------------------------------------------------------------- 1 | #ifndef url_crack_processor_h__ 2 | #define url_crack_processor_h__ 3 | 4 | #include "p2s_ppc/typedef.h" 5 | #include "p2s_ppc/server.hpp" 6 | #include "urlcrack/crack_urls_adapter.hpp" 7 | 8 | NAMESPACE_BEGIN(ppc); 9 | class p2sppc_server; 10 | 11 | class url_crack_processor 12 | :public basic_engine_object 13 | , public session_processor_base 14 | { 15 | typedef url_crack_processor this_type; 16 | typedef boost::asio::ip::tcp tcp; 17 | SHARED_ACCESS_DECLARE; 18 | typedef http::http_connection_base connection_type; 19 | typedef boost::shared_ptr connection_sptr; 20 | typedef boost::weak_ptr connection_wptr; 21 | 22 | typedef urlcrack::crack_adapter crack_adapter; 23 | typedef boost::shared_ptr crack_adapter_sptr; 24 | typedef boost::weak_ptr crack_adapter_wptr; 25 | typedef boost::shared_ptr ppc_server_sptr; 26 | 27 | typedef std::map map_adapter_socket; 28 | 29 | protected: 30 | url_crack_processor(ppc_server_sptr svr); 31 | virtual ~url_crack_processor(); 32 | 33 | public: 34 | static shared_ptr create(ppc_server_sptr svr) 35 | { 36 | return shared_ptr(new this_type( svr), 37 | shared_access_destroy() 38 | ); 39 | } 40 | virtual bool process(const uri& u, const http::request& req, 41 | const connection_sptr& sock); 42 | 43 | private: 44 | void write_urls(const std::vector& _urls, crack_adapter_wptr _adapter); 45 | 46 | private: 47 | map_adapter_socket crack_adapters_; 48 | timed_keeper_set adapters_delay_destroy_; 49 | ppc_server_sptr ppc_server_; 50 | }; 51 | 52 | NAMESPACE_END(ppc); 53 | 54 | #endif // url_crack_processor_h__ 55 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/utility.cpp: -------------------------------------------------------------------------------- 1 | #include "p2s_ppc/utility.h" 2 | #include "p2engine/p2engine/macro.hpp" 3 | #include 4 | NAMESPACE_BEGIN(ppc) 5 | boost::property_tree::ptree get_string_ptree(const std::string& _str_xml_data) 6 | { 7 | boost::property_tree::ptree res_tree; 8 | std::stringstream stream_buf; 9 | stream_buf.str(_str_xml_data); 10 | 11 | try{ 12 | boost::property_tree::xml_parser::read_xml(stream_buf, res_tree); 13 | }catch(...){} 14 | 15 | return res_tree; 16 | } 17 | 18 | std::string get_ptree_string(const boost::property_tree::ptree& pt) 19 | { 20 | std::stringstream ssm; 21 | try 22 | { 23 | boost::property_tree::xml_parser::write_xml(ssm, pt); 24 | }catch(...){} 25 | 26 | return ssm.str(); 27 | } 28 | 29 | std::string get_error_xml_string(const int error_code, const std::string& msg) 30 | { 31 | const std::string root_key = "datainfo"; 32 | const std::string error_key = "errcode"; 33 | const std::string error_msg_key = "msg"; 34 | boost::property_tree::ptree pt; 35 | 36 | pt.add(root_key + "." + error_key, error_code); 37 | pt.add(root_key + "." + error_msg_key, msg); 38 | 39 | std::stringstream ssm; 40 | try 41 | { 42 | boost::property_tree::xml_parser::write_xml(ssm, pt); 43 | }catch(...){} 44 | 45 | return ssm.str(); 46 | } 47 | 48 | NAMESPACE_END(ppc) -------------------------------------------------------------------------------- /src/app/p2s_ppc/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef _P2S_PPC_UTILITY_ 2 | #define _P2S_PPC_UTILITY_ 3 | #include 4 | namespace ppc 5 | { 6 | boost::property_tree::ptree get_string_ptree(const std::string& _str_xml_data); 7 | 8 | std::string get_ptree_string(const boost::property_tree::ptree& pt); 9 | 10 | std::string get_error_xml_string(const int error_code, const std::string& msg); 11 | } 12 | #endif //_P2S_PPC_UTILITY_ -------------------------------------------------------------------------------- /src/app/p2s_ppc/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2S_PPC_VERSION 2 | #define __P2S_PPC_VERSION 3 | 4 | //#define P2S_PPC_VERSION "2.0.0 Beta" 5 | 6 | //scheduling����ʹ��һ����ʱ��������CPU���� 7 | //#define P2S_PPC_VERSION "2.0.1" 8 | 9 | //#define P2S_PPC_VERSION "2.0.2" 10 | 11 | //Fix:�޸�tcp socket����linger������TIME_WAIT 12 | //#define P2S_PPC_VERSION "2.0.3" 13 | 14 | //����iframe�����ٻ�̨�ٶ� 15 | //#define P2S_PPC_VERSION "2.0.4" 16 | 17 | //����P2engine��udp.sendΪudp.async_send 18 | #define P2S_PPC_VERSION "2.0.5" 19 | 20 | #endif//BPI_MDS_VERSION 21 | -------------------------------------------------------------------------------- /src/app/p2s_ppc/viewing_state_processor.h: -------------------------------------------------------------------------------- 1 | #ifndef viewing_state_processor_h__ 2 | #define viewing_state_processor_h__ 3 | 4 | #include "p2s_ppc/typedef.h" 5 | #include "p2s_ppc/server.hpp" 6 | 7 | 8 | NAMESPACE_BEGIN(ppc) 9 | 10 | class viewing_state_processor 11 | :public basic_engine_object 12 | , public session_processor_base 13 | { 14 | typedef viewing_state_processor this_type; 15 | SHARED_ACCESS_DECLARE; 16 | 17 | typedef http::http_connection_base connection_type; 18 | typedef boost::shared_ptr connection_sptr; 19 | 20 | 21 | protected: 22 | viewing_state_processor(boost::shared_ptr svr); 23 | virtual ~viewing_state_processor(); 24 | 25 | public: 26 | static shared_ptr create(boost::shared_ptr svr) 27 | { 28 | return shared_ptr(new this_type( svr), 29 | shared_access_destroy() 30 | ); 31 | } 32 | 33 | bool process(const uri& u, const http::request& req, const connection_sptr& sock); 34 | 35 | protected: 36 | static void handle_sentout_and_close(connection_sptr sock); 37 | 38 | private: 39 | boost::weak_ptr p2sppc_server_; 40 | }; 41 | 42 | 43 | NAMESPACE_END(ppc) 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/app/p2s_shunt/alive_alarm.cpp: -------------------------------------------------------------------------------- 1 | #include "common/common.h" 2 | #include "p2s_shunt/alive_alarm.h" 3 | #include "p2s_shunt/version.h" 4 | #include "p2s_shunt/shunt.pb.h" 5 | #include "app_common/interprocess.h" 6 | #include "shunt/shunt.h" 7 | 8 | progress_alive_alarm::progress_alive_alarm(const std::string&id, 9 | p2sshunt& shunt, int guardPort) 10 | : shunt_(shunt) 11 | { 12 | DEBUG_SCOPE( 13 | std::cout << "-------------------alarm on port: " << guardPort << "\n"; 14 | ); 15 | } 16 | 17 | progress_alive_alarm::~progress_alive_alarm() 18 | { 19 | if (timer_) 20 | timer_->cancel(); 21 | } 22 | 23 | void progress_alive_alarm::start(boost::shared_ptr proxy) 24 | { 25 | interprocess_client_ = proxy; 26 | 27 | if (!timer_) 28 | { 29 | timer_ = rough_timer::create(shunt_.get_io_service()); 30 | timer_->set_obj_desc("p2s_shunt::progress_alive_alarm::timer_"); 31 | timer_->register_time_handler(boost::bind(&this_type::on_timer, this)); 32 | timer_->async_keep_waiting(millisec(random(0, 10000)), millisec(10000)); 33 | } 34 | } 35 | 36 | void progress_alive_alarm::on_timer() 37 | { 38 | shunt_alive::Alive msg; 39 | msg.set_id(shunt_.id()); 40 | msg.set_is_connected(shunt_.is_connected()); 41 | msg.set_kbps((int)shunt_.average_media_speed()); 42 | msg.set_pid(getpid()); 43 | 44 | LogInfo("id: %s, is_connected: %d, kbps:%2f", shunt_.id(), shunt_.is_connected(), shunt_.average_media_speed()); 45 | 46 | if (interprocess_client_.lock()) 47 | interprocess_client_.lock()->send(serialize(msg), control_cmd_msg::alive_alarm); 48 | } 49 | -------------------------------------------------------------------------------- /src/app/p2s_shunt/alive_alarm.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMMON_AUTH 2 | #define __COMMON_AUTH 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace p2control{ 9 | class interprocess_client; 10 | } 11 | namespace p2shunt{ 12 | class p2sshunt; 13 | } 14 | 15 | using namespace p2engine; 16 | using namespace p2shunt; 17 | using namespace p2control; 18 | 19 | class progress_alive_alarm 20 | :public boost::enable_shared_from_this < progress_alive_alarm > 21 | { 22 | typedef progress_alive_alarm this_type; 23 | typedef http::basic_http_connection http_connection; 24 | SHARED_ACCESS_DECLARE; 25 | 26 | protected: 27 | progress_alive_alarm(const std::string&id, p2sshunt& shunt, int guardPort); 28 | virtual ~progress_alive_alarm(); 29 | 30 | public: 31 | static shared_ptr create(const std::string&id, p2sshunt& shunt, int guardPort) 32 | { 33 | return shared_ptr(new this_type(id, shunt, guardPort), 34 | shared_access_destroy() 35 | ); 36 | } 37 | void start(boost::shared_ptr); 38 | 39 | protected: 40 | void on_timer(); 41 | 42 | private: 43 | p2sshunt& shunt_; 44 | boost::shared_ptr timer_; 45 | boost::weak_ptr interprocess_client_; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/app/p2s_shunt/make_proto.bat: -------------------------------------------------------------------------------- 1 | protoc.exe --cpp_out=./ shunt.proto -------------------------------------------------------------------------------- /src/app/p2s_shunt/nat_type: -------------------------------------------------------------------------------- 1 | type=4 2 | timestamp=1332156407 3 | -------------------------------------------------------------------------------- /src/app/p2s_shunt/p2s_shunt.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/app/p2s_shunt/p2s_shunt.vcproj -------------------------------------------------------------------------------- /src/app/p2s_shunt/p2s_shunt.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/app/p2s_shunt/shunt.proto: -------------------------------------------------------------------------------- 1 | package shunt_alive; 2 | option optimize_for = LITE_RUNTIME; 3 | message Alive { 4 | required bytes id = 1; 5 | required int32 kbps = 2; 6 | required bool is_connected = 3; 7 | optional int32 pid=4; 8 | } -------------------------------------------------------------------------------- /src/app/p2s_shunt/shunt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | http://zb.v.qq.com:1863/?progid=2342060367&ostype=ios,neimenggu 5 | 20 6 | 7 | 8 | udp://127.0.0.1:2008 9 | http://0.0.0.0:58888 10 | 11 | -------------------------------------------------------------------------------- /src/app/p2s_shunt/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __BPI_SHUNT_VERSION 2 | #define __BPI_SHUNT_VERSION 3 | 4 | #define BPI_SHUNT_VERSION "2.0.0 Beta" 5 | 6 | #endif//__BPI_SHUNT_VERSION -------------------------------------------------------------------------------- /src/app/p2s_shunt_control/p2s_shunt_control.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/app/p2s_shunt_control/p2s_shunt_control.vcproj -------------------------------------------------------------------------------- /src/app/p2s_shunt_control/p2s_shunt_control.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/p2s_shunt_control/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2S_SHUNT_CONTROL_VERSION 2 | #define __P2S_SHUNT_CONTROL_VERSION 3 | 4 | #define P2S_SHUNT_CONTROL_VERSION "2.0.0 Beta" 5 | 6 | #endif//__P2S_MDS_CONTROL_VERSION -------------------------------------------------------------------------------- /src/app/p2s_tracker/p2s_tracker.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/p2s_tracker/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2S_TRACKER_VERSION 2 | #define __P2S_TRACKER_VERSION 3 | 4 | #define P2S_TRACKER_VERSION "2.0.0" 5 | 6 | #endif//__P2S_TRACKER_VERSION 7 | -------------------------------------------------------------------------------- /src/app/win_service/config.ini: -------------------------------------------------------------------------------- 1 | [service] 2 | name=p2s_test_service #service name 3 | [app] 4 | control_name=p2s_mds_cache.exe #app name controlled by service 5 | #sub_process=xxxx 6 | param_cnt=2 #param count of control app 7 | [param_1] 8 | name=endpoint #name of first param 9 | value=127.0.0.1:9876 #value of first param 10 | [param_2] 11 | name=mlimit #name of second param 12 | value=100 #value of second param 13 | #... 14 | #here can be more param ... 15 | #... -------------------------------------------------------------------------------- /src/app/win_service/service.h: -------------------------------------------------------------------------------- 1 | #ifndef win_service_service_h__ 2 | #define win_service_service_h__ 3 | 4 | #define WIN32_LEAN_AND_MEAN //use windows.h avoid error #error : WinSock.h has already been included 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | enum{MAX_NUM_OF_PROCESS=1}; 13 | 14 | void service_main_proc(); 15 | 16 | /** Window Service **/ 17 | void install(char* pPath, char* pName); 18 | void uninstall(char* pName); 19 | void write_log(char* pFile, char* pMsg); 20 | bool kill_service(char* pName); 21 | bool run_service(char* pName); 22 | void execute_subprocess(); 23 | void proc_monitor_thread(); 24 | bool start_process(int ProcessIndex); 25 | void end_process(int ProcessIndex); 26 | void attach_processNames(); 27 | 28 | 29 | void WINAPI service_main(DWORD dwArgc, LPTSTR *lpszArgv); 30 | void WINAPI service_handler(DWORD fdwControl); 31 | 32 | #endif //win_service_service_h__ 33 | -------------------------------------------------------------------------------- /src/app/win_service/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __P2S_WIN_SERVICE_VERSION 2 | #define __P2S_WIN_SERVICE_VERSION 3 | 4 | #define WIN_SERVICE_VERSION "2.0.0 Beta" 5 | 6 | #endif//__P2S_MDS_CONTROL_VERSION -------------------------------------------------------------------------------- /src/app/win_service/win_service.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/app/win_service/win_service.vcproj -------------------------------------------------------------------------------- /src/app/win_service/win_service.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | 原始程式檔 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/app/win_service/win_service.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/compile_settings/configration.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(SolutionDir) 5 | 6 | 7 | <_ProjectFileVersion>10.0.40219.1 8 | 9 | 10 | 11 | $(BOOST_INCLUDE);$(PROTOBUF_INCLUDE);$(SolutionDir)..\..\..\src\lib\p2engine\;$(SolutionDir)..\..\..\src\lib\;$(SolutionDir)..\..\..\src\lib\p2engine\p2engine\;%(AdditionalIncludeDirectories) 12 | 13 | 14 | libprotobuf-lite.lib;%(AdditionalDependencies) 15 | $(BOOST_LIB);%(AdditionalLibraryDirectories) 16 | 17 | 18 | 19 | 20 | $(SOLUTION_DIR) 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/compile_settings/configration.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 16 | 20 | 21 | -------------------------------------------------------------------------------- /src/compile_settings/libtorrent_upnp.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /src/compile_settings/test_props.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.40219.1 5 | 6 | 7 | 8 | libprotobuf-lite.lib;common.lib;client.lib;server.lib;tracker.lib;iphlpapi.lib;simple_server.lib;asfio.lib;libupnp.lib;%(AdditionalDependencies) 9 | $(BOOST_LIB);$(OUTDIR);%(AdditionalLibraryDirectories) 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/compile_settings/test_props.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /src/lib/app_common/app_common.h: -------------------------------------------------------------------------------- 1 | #ifndef app_common_h__ 2 | #define app_common_h__ 3 | 4 | #include "app_common/interprocess.h" 5 | #include "app_common/mds.pb.h" 6 | #include "app_common/mds_db.h" 7 | #include "app_common/shunt_db.h" 8 | #include "app_common/control_base.h" 9 | #include "app_common/process_killer.h" 10 | #include "app_common/typedef.h" 11 | 12 | #endif //mds_common_h__ 13 | 14 | -------------------------------------------------------------------------------- /src/lib/app_common/app_common.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/app_common/control_base.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/control_base.h -------------------------------------------------------------------------------- /src/lib/app_common/interprocess.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/interprocess.cpp -------------------------------------------------------------------------------- /src/lib/app_common/interprocess.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/interprocess.h -------------------------------------------------------------------------------- /src/lib/app_common/level_db.h: -------------------------------------------------------------------------------- 1 | #ifndef p2s_p2p_app_common_level_db_h__ 2 | #define p2s_p2p_app_common_level_db_h__ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | namespace leveldb{ 9 | class DB; 10 | } 11 | 12 | namespace app_common{ 13 | 14 | class level_db 15 | :public boost::noncopyable 16 | { 17 | public: 18 | explicit level_db(const std::string& dbName); 19 | ~level_db(); 20 | ////////////////////////////////////////////////////////////////////////// 21 | bool put(const std::string& key, const std::string& value, std::string& errorMsg); 22 | bool get(const std::string& key, std::string& value, std::string& errorMsg); 23 | bool del(const std::string& key, std::string& errorMsg); 24 | bool update(const std::string& key, const std::string& value, std::string& errorMsg); 25 | 26 | private: 27 | std::auto_ptr db_; 28 | }; 29 | 30 | }; 31 | 32 | #endif // p2s_p2p_app_common_level_db_h__ 33 | -------------------------------------------------------------------------------- /src/lib/app_common/make.bat: -------------------------------------------------------------------------------- 1 | protoc mds.proto --cpp_out=./ 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/app_common/mds.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/mds.proto -------------------------------------------------------------------------------- /src/lib/app_common/mds_db.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/mds_db.cpp -------------------------------------------------------------------------------- /src/lib/app_common/process_killer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/process_killer.cpp -------------------------------------------------------------------------------- /src/lib/app_common/process_killer.h: -------------------------------------------------------------------------------- 1 | #ifndef process_killer_h__ 2 | #define process_killer_h__ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace p2control{ 11 | 12 | #if defined(BOOST_WINDOWS_API) 13 | typedef DWORD pid_t; 14 | #endif 15 | typedef boost::unordered_set pid_set; 16 | 17 | void kill_all_process(const std::string& name); 18 | bool kill_process_by_id(pid_t processID, bool force=true); 19 | void find_process_ids(pid_set&, const std::string&); 20 | 21 | const std::string get_current_process_name(); 22 | void clear_instance_exist(); 23 | void close_process(const std::string& app_name); 24 | std::string string_native(const std::string&); 25 | bool instance_check(pid_t pid); 26 | }; 27 | 28 | #endif // process_killer_h__ 29 | -------------------------------------------------------------------------------- /src/lib/app_common/protoc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/protoc.exe -------------------------------------------------------------------------------- /src/lib/app_common/shunt_db.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/app_common/shunt_db.cpp -------------------------------------------------------------------------------- /src/lib/app_common/typedef.h: -------------------------------------------------------------------------------- 1 | #ifndef app_common_typedef_h__ 2 | #define app_common_typedef_h__ 3 | 4 | #include "shunt/typedef.h" 5 | 6 | namespace p2control{ 7 | typedef p2shunt::shunt_xml_param shunt_xml_param; 8 | typedef p2shunt::host_name_t host_name_t; 9 | typedef p2shunt::user_name_t user_name_t; 10 | typedef p2shunt::password_t password_t; 11 | typedef p2shunt::db_name_t db_name_t; 12 | }; 13 | 14 | #endif // app_common_typedef_h__ 15 | -------------------------------------------------------------------------------- /src/lib/asfio/asfio.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/asfio/async_dskcache.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/asfio/async_dskcache.h -------------------------------------------------------------------------------- /src/lib/asfio/config.h: -------------------------------------------------------------------------------- 1 | #ifndef async_file_config_h__ 2 | #define async_file_config_h__ 3 | 4 | #include 5 | 6 | namespace asfio{ 7 | 8 | using namespace p2engine; 9 | 10 | } 11 | 12 | #endif // async_file_config_h__ 13 | -------------------------------------------------------------------------------- /src/lib/asfio/disk_cache_impl.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/asfio/disk_cache_impl.hpp -------------------------------------------------------------------------------- /src/lib/asfio/new_timeshift_io.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/asfio/new_timeshift_io.cpp -------------------------------------------------------------------------------- /src/lib/asfio/new_timeshift_io.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/asfio/new_timeshift_io.hpp -------------------------------------------------------------------------------- /src/lib/client/__client: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/__client -------------------------------------------------------------------------------- /src/lib/client/client.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/lib/client/client_service.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/client_service.cpp -------------------------------------------------------------------------------- /src/lib/client/client_service.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/client_service.h -------------------------------------------------------------------------------- /src/lib/client/client_service_logic.cpp: -------------------------------------------------------------------------------- 1 | #include "client/client_service.h" 2 | #include "client/client_service_logic.h" 3 | 4 | NAMESPACE_BEGIN(p2client); 5 | 6 | client_service_logic_base::client_service_logic_base(io_service& iosvc) 7 | :basic_engine_object(iosvc) 8 | , basic_client_object(client_param_sptr()) 9 | { 10 | set_obj_desc("client_service_logic"); 11 | } 12 | 13 | client_service_logic_base::~client_service_logic_base() 14 | { 15 | stop_service(); 16 | } 17 | 18 | void client_service_logic_base::start_service(const client_param_base& param) 19 | { 20 | if(client_service_)//already started 21 | return; 22 | 23 | this->client_param_=create_client_param_sptr(param); 24 | client_service_=client_service::create(get_io_service(), get_client_param_sptr()); 25 | get_io_service().post(make_alloc_handler( 26 | boost::bind(&client_service::start, client_service_, SHARED_OBJ_FROM_THIS) 27 | )); 28 | } 29 | 30 | void client_service_logic_base::stop_service(bool flush) 31 | { 32 | if(client_service_) 33 | { 34 | client_service_->stop(flush); 35 | client_service_.reset(); 36 | } 37 | } 38 | 39 | void client_service_logic_base::set_play_offset(int64_t offset) 40 | { 41 | if(client_service_) 42 | client_service_->set_play_offset(offset); 43 | } 44 | 45 | NAMESPACE_END(p2client); 46 | -------------------------------------------------------------------------------- /src/lib/client/client_service_logic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/client_service_logic.h -------------------------------------------------------------------------------- /src/lib/client/hub/hub_scheduling.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/hub/hub_scheduling.cpp -------------------------------------------------------------------------------- /src/lib/client/hub/hub_scheduling.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/hub/hub_scheduling.h -------------------------------------------------------------------------------- /src/lib/client/hub/hub_topology.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/hub/hub_topology.cpp -------------------------------------------------------------------------------- /src/lib/client/hub/hub_topology.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/hub/hub_topology.h -------------------------------------------------------------------------------- /src/lib/client/nat.h: -------------------------------------------------------------------------------- 1 | // 2 | // const_define.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | 10 | #ifndef p2pnet__nat_h__ 11 | #define p2pnet__nat_h__ 12 | 13 | namespace p2client{ 14 | int get_local_nat_type(); 15 | } 16 | 17 | #endif//p2pnet__nat_h__ 18 | 19 | -------------------------------------------------------------------------------- /src/lib/client/neighbor_map.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/neighbor_map.cpp -------------------------------------------------------------------------------- /src/lib/client/overlay.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/overlay.cpp -------------------------------------------------------------------------------- /src/lib/client/overlay.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/overlay.h -------------------------------------------------------------------------------- /src/lib/client/pa_handler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/pa_handler.h -------------------------------------------------------------------------------- /src/lib/client/peer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/peer.cpp -------------------------------------------------------------------------------- /src/lib/client/peer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/peer.h -------------------------------------------------------------------------------- /src/lib/client/peer_connection.cpp: -------------------------------------------------------------------------------- 1 | #include "client/peer_connection.h" 2 | 3 | NAMESPACE_BEGIN(p2client); 4 | 5 | peer_connection::peer_connection(io_service& ios, bool realTimeUsage, bool isPassive) 6 | :message_socket(ios, realTimeUsage, isPassive) 7 | , local_id_(INVALID_ID) 8 | , local_uuid_(INVALID_ID) 9 | {} 10 | 11 | peer_connection::~peer_connection() 12 | { 13 | if (peer_)peer_->be_member(this); 14 | } 15 | 16 | bool peer_connection::is_link_local() 17 | { 18 | if (!is_link_local_.is_initialized()) 19 | { 20 | if (is_connected()) 21 | { 22 | error_code ec; 23 | is_link_local_ = is_local(remote_endpoint(ec).address()); 24 | } 25 | else 26 | return false; 27 | } 28 | return is_link_local_.get(); 29 | } 30 | 31 | NAMESPACE_END(p2client); 32 | -------------------------------------------------------------------------------- /src/lib/client/peer_connection.h: -------------------------------------------------------------------------------- 1 | // 2 | // peer_connection.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | #ifndef peer_peer_connection_base_h__ 10 | #define peer_peer_connection_base_h__ 11 | 12 | #include "client/typedef.h" 13 | #include "client/peer.h" 14 | 15 | namespace p2client{ 16 | 17 | class peer_connection 18 | :public message_socket 19 | { 20 | typedef peer_connection this_type; 21 | SHARED_ACCESS_DECLARE; 22 | 23 | public: 24 | typedef peer_connection connection_base_type; 25 | 26 | peer_connection(io_service& ios, bool realTimeUsage, bool isPassive); 27 | virtual ~peer_connection(); 28 | 29 | const peer_sptr& get_peer()const{return peer_;} 30 | void set_peer(const peer_sptr& p){peer_=p;peer_->set_connection(SHARED_OBJ_FROM_THIS);} 31 | bool is_link_local(); 32 | int local_id()const{return local_id_;} 33 | void local_id(int id){ local_id_=id;} 34 | int local_uuid()const{return local_uuid_;} 35 | void local_uuid(int id){ local_uuid_=id;} 36 | 37 | protected: 38 | peer_sptr peer_; 39 | int local_id_; 40 | int local_uuid_; 41 | boost::optional is_link_local_; 42 | bool natpunched_; 43 | }; 44 | 45 | typedef basic_urdp_connection urdp_peer_connection; 46 | typedef basic_trdp_connection trdp_peer_connection; 47 | 48 | typedef basic_acceptor peer_acceptor; 49 | typedef basic_urdp_acceptor 50 | urdp_peer_acceptor; 51 | typedef basic_trdp_acceptor 52 | trdp_peer_acceptor; 53 | 54 | PTR_TYPE_DECLARE(peer_connection); 55 | PTR_TYPE_DECLARE(peer_acceptor); 56 | PTR_TYPE_DECLARE(urdp_peer_connection); 57 | PTR_TYPE_DECLARE(trdp_peer_connection); 58 | PTR_TYPE_DECLARE(urdp_peer_acceptor); 59 | PTR_TYPE_DECLARE(trdp_peer_acceptor); 60 | 61 | } 62 | 63 | #endif//peer_peer_connection_base_h__ -------------------------------------------------------------------------------- /src/lib/client/scheduling_base.h: -------------------------------------------------------------------------------- 1 | // 2 | // overlay.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | #ifndef peer_scheduling_base_h__ 9 | #define peer_scheduling_base_h__ 10 | 11 | #include "client/typedef.h" 12 | 13 | namespace p2client{ 14 | 15 | class scheduling_base 16 | : public basic_engine_object 17 | , public basic_client_object 18 | { 19 | typedef scheduling_base this_type; 20 | SHARED_ACCESS_DECLARE; 21 | 22 | friend class overlay; 23 | 24 | protected: 25 | scheduling_base(io_service& ios, const client_param_sptr& param) 26 | :basic_engine_object(ios) 27 | , basic_client_object(param) 28 | {} 29 | virtual ~scheduling_base(){} 30 | 31 | public: 32 | virtual void start()=0; 33 | virtual void stop(bool flush=false)=0; 34 | virtual void set_play_offset(int64_t offset)=0; 35 | virtual void process_recvd_buffermap(const buffermap_info& bufmap, peer_connection* p)=0; 36 | virtual void send_handshake_to(peer_connection* conn)=0; 37 | virtual void register_message_handler(peer_connection* conn)=0; 38 | virtual void neighbor_erased(const peer_id_t& id)=0; 39 | }; 40 | 41 | } 42 | #endif//peer_topology_base_h__ 43 | -------------------------------------------------------------------------------- /src/lib/client/stream/absent_packet_info.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/absent_packet_info.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/absent_packet_info.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/absent_packet_info.h -------------------------------------------------------------------------------- /src/lib/client/stream/absent_packet_list.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/absent_packet_list.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/absent_packet_list.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/absent_packet_list.h -------------------------------------------------------------------------------- /src/lib/client/stream/buffer_manager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/buffer_manager.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/buffer_manager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/buffer_manager.h -------------------------------------------------------------------------------- /src/lib/client/stream/heuristic_scheduling_strategy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/heuristic_scheduling_strategy.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/heuristic_scheduling_strategy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/heuristic_scheduling_strategy.h -------------------------------------------------------------------------------- /src/lib/client/stream/live_media_dispatcher.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/live_media_dispatcher.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/live_media_dispatcher.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/live_media_dispatcher.h -------------------------------------------------------------------------------- /src/lib/client/stream/media_dispatcher.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/media_dispatcher.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/media_dispatcher.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/media_dispatcher.h -------------------------------------------------------------------------------- /src/lib/client/stream/scheduling_typedef.cpp: -------------------------------------------------------------------------------- 1 | #include "client/stream/scheduling_typedef.h" 2 | #include "client/stream/stream_scheduling.h" 3 | 4 | NAMESPACE_BEGIN(p2client); 5 | 6 | basic_stream_scheduling::basic_stream_scheduling(stream_scheduling& scheduling) 7 | :basic_client_object(scheduling.get_client_param_sptr()) 8 | , basic_engine_object(scheduling.get_io_service()) 9 | , scheduling_(&scheduling) 10 | { 11 | } 12 | 13 | basic_stream_scheduling::~basic_stream_scheduling() 14 | { 15 | } 16 | 17 | NAMESPACE_END(p2client); 18 | 19 | -------------------------------------------------------------------------------- /src/lib/client/stream/scheduling_typedef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/scheduling_typedef.h -------------------------------------------------------------------------------- /src/lib/client/stream/stream_monitor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_monitor.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/stream_monitor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_monitor.h -------------------------------------------------------------------------------- /src/lib/client/stream/stream_scheduling.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_scheduling.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/stream_scheduling.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_scheduling.h -------------------------------------------------------------------------------- /src/lib/client/stream/stream_seed.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_seed.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/stream_seed.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_seed.h -------------------------------------------------------------------------------- /src/lib/client/stream/stream_topology.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_topology.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/stream_topology.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/stream_topology.h -------------------------------------------------------------------------------- /src/lib/client/stream/vod_media_dispatcher.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/vod_media_dispatcher.cpp -------------------------------------------------------------------------------- /src/lib/client/stream/vod_media_dispatcher.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/stream/vod_media_dispatcher.h -------------------------------------------------------------------------------- /src/lib/client/tracker_manager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/tracker_manager.cpp -------------------------------------------------------------------------------- /src/lib/client/tracker_manager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/client/tracker_manager.h -------------------------------------------------------------------------------- /src/lib/common/common.h: -------------------------------------------------------------------------------- 1 | #ifndef common_common_h__ 2 | #define common_common_h__ 3 | 4 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 5 | # pragma once 6 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 7 | 8 | #include "common/config.h" 9 | #include "common/typedef.h" 10 | #include "common/bignumber.h" 11 | #include "common/utility.h" 12 | #include "common/const_define.h" 13 | #include "common/message_type.h" 14 | #include "common/media_packet.h" 15 | #include "common/packet_buffer.h" 16 | #include "common/upload_capacity_detector.h" 17 | #include "common/smoother.h" 18 | #include "common/parameter.h" 19 | #include "common/md5.h" 20 | #include "common/curve25519.h" 21 | #include "common/fec.h" 22 | #include "common/security_policy.h" 23 | #include "common/policy.h" 24 | 25 | #endif//common_common_h__ 26 | -------------------------------------------------------------------------------- /src/lib/common/common.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | 6 | -------------------------------------------------------------------------------- /src/lib/common/config.h: -------------------------------------------------------------------------------- 1 | #ifndef common_config_h__ 2 | #define common_config_h__ 3 | 4 | #include 5 | namespace p2common{ 6 | 7 | using namespace p2engine; 8 | }; 9 | #endif//common_common_h__ 10 | -------------------------------------------------------------------------------- /src/lib/common/const_define.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/const_define.h -------------------------------------------------------------------------------- /src/lib/common/curve25519.h: -------------------------------------------------------------------------------- 1 | #ifndef __CURVE25519_H__ 2 | #define __CURVE25519_H__ 3 | 4 | #ifdef __cplusplus 5 | extern "C" 6 | { 7 | #endif 8 | 9 | int curve25519(void *mypublic, const void*secret, const void *basepoint); 10 | 11 | #ifdef __cplusplus 12 | } 13 | #endif 14 | 15 | #endif//__CURVE25519_H__ 16 | -------------------------------------------------------------------------------- /src/lib/common/fec.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/fec.cpp -------------------------------------------------------------------------------- /src/lib/common/fec.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_FEC_H__ 2 | #define _COMMON_FEC_H__ 3 | 4 | #include "common/config.h" 5 | #include "common/packet_buffer.h" 6 | #include 7 | 8 | namespace p2common{ 9 | 10 | class packet_fec 11 | { 12 | public: 13 | packet_fec(int m, bool decoder):m_(m), mm_(0), len_header_(0), decoder_(decoder){} 14 | void reset() 15 | { 16 | len_header_=0; 17 | buf_.resize(0);//must set to size 0 18 | mm_=0; 19 | } 20 | bool operator()(const safe_buffer& mediaPacket, safe_buffer& result); 21 | private: 22 | const int m_; 23 | int mm_; 24 | int32_t len_header_; 25 | std::string buf_; 26 | bool decoder_; 27 | }; 28 | 29 | class fec_encoder 30 | { 31 | public: 32 | fec_encoder(); 33 | bool operator()(const media_packet& pkt, std::vector&results); 34 | 35 | private: 36 | std::vector fec_; 37 | std::vector fec_packets_; 38 | bool found_first_fec_seqno_; 39 | }; 40 | 41 | class fec_decoder 42 | { 43 | public: 44 | fec_decoder(); 45 | 46 | bool operator()(seqno_t theLostSeqno, const packet_buffer& media_packets, 47 | const std::map >& fecPkts, 48 | const std::string& pktCasString, timestamp_t now, 49 | safe_buffer&decodeResult 50 | ); 51 | 52 | private: 53 | packet_fec packet_fec_decoder_; 54 | }; 55 | } 56 | 57 | 58 | #endif//_COMMON_FEC_H__ 59 | -------------------------------------------------------------------------------- /src/lib/common/make.bat: -------------------------------------------------------------------------------- 1 | protoc message.proto --cpp_out=./ 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/common/make_pa_proto.bat: -------------------------------------------------------------------------------- 1 | protoc.exe --cpp_out=./ pa_message.proto -------------------------------------------------------------------------------- /src/lib/common/media_packet.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/media_packet.h -------------------------------------------------------------------------------- /src/lib/common/message.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/message.proto -------------------------------------------------------------------------------- /src/lib/common/message_type.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/message_type.h -------------------------------------------------------------------------------- /src/lib/common/pa_message.proto: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/pa_message.proto -------------------------------------------------------------------------------- /src/lib/common/packet_buffer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/packet_buffer.cpp -------------------------------------------------------------------------------- /src/lib/common/parameter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/parameter.cpp -------------------------------------------------------------------------------- /src/lib/common/parameter.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/parameter.h -------------------------------------------------------------------------------- /src/lib/common/policy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/policy.cpp -------------------------------------------------------------------------------- /src/lib/common/policy.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/policy.h -------------------------------------------------------------------------------- /src/lib/common/protoc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/protoc.exe -------------------------------------------------------------------------------- /src/lib/common/security_policy.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/security_policy.cpp -------------------------------------------------------------------------------- /src/lib/common/security_policy.h: -------------------------------------------------------------------------------- 1 | // 2 | // security_policy.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | 10 | #ifndef common_security_policy_h__ 11 | #define common_security_policy_h__ 12 | 13 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 14 | # pragma once 15 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 16 | 17 | #include //std::pair 18 | 19 | #include "common/parameter.h" 20 | #include "common/media_packet.h" 21 | 22 | namespace p2common{ 23 | 24 | class security_policy 25 | { 26 | public: 27 | static std::string get_machine_id(); 28 | static std::string generate_shared_key(const std::string& digest, const std::string &hispublic); 29 | static std::pair generate_key_pair(); 30 | 31 | static std::string client_encrypt_tracker_challenge(const std::string& challenge, const client_param_sptr&); 32 | 33 | static int64_t signature_mediapacket(const media_packet& pkt, const std::string& channelID); 34 | static void cas_mediapacket(media_packet& pkt, const std::string& casKeyStr); 35 | }; 36 | } 37 | 38 | #endif//common_security_policy_h__ 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/lib/common/smoother.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/smoother.cpp -------------------------------------------------------------------------------- /src/lib/common/smoother.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/smoother.h -------------------------------------------------------------------------------- /src/lib/common/tsparse.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/tsparse.cpp -------------------------------------------------------------------------------- /src/lib/common/tsparse.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/tsparse.h -------------------------------------------------------------------------------- /src/lib/common/upload_capacity_detect.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/upload_capacity_detect.cpp -------------------------------------------------------------------------------- /src/lib/common/upload_capacity_detector.h: -------------------------------------------------------------------------------- 1 | #ifndef UPLOAD_CAPACITY_DETECTOR_H__ 2 | #define UPLOAD_CAPACITY_DETECTOR_H__ 3 | 4 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 5 | # pragma once 6 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 7 | 8 | namespace p2common{ 9 | 10 | int get_upload_capacity(); 11 | 12 | } 13 | 14 | #endif// 15 | -------------------------------------------------------------------------------- /src/lib/common/utility.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/utility.cpp -------------------------------------------------------------------------------- /src/lib/common/utility.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/common/utility.h -------------------------------------------------------------------------------- /src/lib/httpdownload/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 静态库:httpdownload 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 httpdownload 库项目。 6 | 7 | 本文件概要介绍组成 httpdownload 应用程序的每个文件的内容。 8 | 9 | 10 | httpdownload.vcproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件, 12 | 其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 13 | 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | 17 | StdAfx.h, StdAfx.cpp 18 | 这些文件用于生成名为 httpdownload.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | 其他注释: 22 | 23 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 24 | 25 | ///////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /src/lib/httpdownload/http_download_base.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/httpdownload/http_download_base.cpp -------------------------------------------------------------------------------- /src/lib/httpdownload/http_download_base.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/httpdownload/http_download_base.hpp -------------------------------------------------------------------------------- /src/lib/httpdownload/http_download_file.cpp: -------------------------------------------------------------------------------- 1 | #include "httpdownload/http_download_file.hpp" 2 | #include "asfio/os_api.hpp" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace http_download{ 9 | 10 | void http_download_file::start(const std::string& _url) 11 | { 12 | http_download_base::start(_url); 13 | if (pf_) 14 | { 15 | asfio::fileclose(pf_); 16 | pf_ = NULL; 17 | } 18 | } 19 | 20 | void http_download_file::__write(const char* buf, uint32_t len) 21 | { 22 | boost::system::error_code error; 23 | if (!pf_ && boost::filesystem::status(filename_.c_str()).type() == boost::filesystem::file_not_found) 24 | { 25 | pf_ = asfio::fileopen(filename_, "wb+", error); 26 | } 27 | else if (!pf_) 28 | { 29 | pf_ = asfio::fileopen(filename_, "ab+", error); 30 | } 31 | asfio::filewrite(buf, len, pf_, error); 32 | if (100 == status_) 33 | { 34 | asfio::fileclose(pf_); 35 | } 36 | http_download_base::__write(buf, len); 37 | } 38 | 39 | void http_download_file::set_filename(const std::string& _filename) 40 | { 41 | filename_ = _filename; 42 | } 43 | 44 | }; -------------------------------------------------------------------------------- /src/lib/httpdownload/http_download_file.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _http_download_file_ 2 | #define _http_download_file_ 3 | 4 | #include "httpdownload/http_download_base.hpp" 5 | 6 | namespace http_download{ 7 | class http_download_file: public http_download_base 8 | { 9 | typedef http_download_file this_type; 10 | SHARED_ACCESS_DECLARE; 11 | 12 | public: 13 | static shared_ptr create(io_service& ios) 14 | { 15 | return boost::shared_ptr( 16 | new this_type(ios), shared_access_destroy() 17 | ); 18 | } 19 | virtual void start(const std::string& _url); 20 | virtual void __write(const char* buf, uint32_t len); 21 | void set_filename(const std::string& _filename); 22 | 23 | protected: 24 | http_download_file(io_service& ios):http_download_base(ios), pf_(NULL){}; 25 | ~http_download_file(){}; 26 | 27 | private: 28 | std::string filename_; 29 | FILE* pf_; 30 | 31 | }; 32 | } 33 | #endif //_http_download_file_ -------------------------------------------------------------------------------- /src/lib/httpdownload/http_download_memory.cpp: -------------------------------------------------------------------------------- 1 | #include "httpdownload/http_download_memory.hpp" 2 | 3 | #include "p2engine/raw_buffer.hpp" 4 | #include "p2engine/io.hpp" 5 | namespace http_download 6 | { 7 | 8 | http_download_memory::~http_download_memory() 9 | { 10 | if(!bFinish_) 11 | { 12 | failed_down(); 13 | } 14 | } 15 | 16 | void http_download_memory::start(const std::string& _url) 17 | { 18 | http_download_base::start(_url); 19 | recbuf_.clear(); 20 | } 21 | 22 | void http_download_memory::connect_overtime() 23 | { 24 | http_download_base::connect_overtime(); 25 | 26 | failed_down(); 27 | } 28 | 29 | void http_download_memory::__write(const char* buf, uint32_t len) 30 | { 31 | try 32 | { 33 | safe_buffer_io bufio(&recbuf_); 34 | bufio.write(buf, len); 35 | 36 | if(100 == status_) 37 | { 38 | finish_down(); 39 | } 40 | } 41 | catch (std::exception& e) 42 | { 43 | std::cout<<"http_download_memory error:"<(recbuf_), buffer_size(recbuf_)); 68 | all_downloal_signal_(content); 69 | } 70 | } 71 | 72 | void http_download_memory::failed_down() 73 | { 74 | bFinish_ = true; 75 | 76 | if(!all_downloal_signal_.empty()) 77 | all_downloal_signal_(""); 78 | } 79 | }; -------------------------------------------------------------------------------- /src/lib/httpdownload/http_download_memory.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _http_download_memory 2 | #define _http_download_memory 3 | 4 | #include "httpdownload/http_download_base.hpp" 5 | 6 | namespace http_download{ 7 | 8 | class http_download_memory : public http_download_base 9 | { 10 | typedef http_download_memory this_type; 11 | typedef boost::function all_download_callback; 12 | typedef boost::function partial_download_callback; 13 | SHARED_ACCESS_DECLARE; 14 | public: 15 | static shared_ptr create(io_service& ios) 16 | { 17 | return boost::shared_ptr( 18 | new this_type(ios), shared_access_destroy() 19 | ); 20 | } 21 | 22 | void register_down_finish_handler(const all_download_callback& h) 23 | { 24 | all_downloal_signal_ = h; 25 | } 26 | 27 | void register_down_media_finish_handler(partial_download_callback h) 28 | { 29 | partial_downloal_signal_ = h; 30 | } 31 | 32 | virtual void start(const std::string& _url); 33 | virtual void connect_overtime(); 34 | virtual void __write(const char* buf, uint32_t len); 35 | protected: 36 | http_download_memory(io_service& ios) :http_download_base(ios), recbuf_() 37 | { 38 | bFinish_ = false; 39 | }; 40 | 41 | ~http_download_memory(); 42 | virtual void on_disconnected(const error_code& ec); 43 | void finish_down(); 44 | void failed_down(); 45 | private: 46 | safe_buffer recbuf_; 47 | bool bFinish_; 48 | all_download_callback all_downloal_signal_; 49 | partial_download_callback partial_downloal_signal_; 50 | }; 51 | }; 52 | 53 | #endif //_http_download_memory -------------------------------------------------------------------------------- /src/lib/httpdownload/httpdownload.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/httpdownload/httpdownload.vcproj -------------------------------------------------------------------------------- /src/lib/httpdownload/httpdownload.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | src 16 | 17 | 18 | src 19 | 20 | 21 | src 22 | 23 | 24 | 25 | 26 | include 27 | 28 | 29 | include 30 | 31 | 32 | include 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/lib/httpdownload/httpdownload.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/lib_template/lib_template.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/lib_template/lib_template.vcproj -------------------------------------------------------------------------------- /src/lib/libupnp/libtorrent_upnp.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/lib/libupnp/libtorrent_upnp.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/libupnp/libupnp.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/libupnp/libupnp.vcproj -------------------------------------------------------------------------------- /src/lib/libupnp/src/upnp.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/libupnp/src/upnp.cpp -------------------------------------------------------------------------------- /src/lib/libupnp/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef utility_h__ 2 | #define utility_h__ 3 | 4 | #include "p2engine/push_warning_option.hpp" 5 | #include 6 | #include 7 | #include "p2engine/pop_warning_option.hpp" 8 | 9 | #include 10 | 11 | namespace libupnp 12 | { 13 | typedef boost::int64_t size_type; 14 | typedef boost::uint64_t unsigned_size_type; 15 | 16 | typedef p2engine::address address; 17 | typedef p2engine::address_v4 address_v4; 18 | typedef p2engine::address_v6 address_v6; 19 | 20 | typedef boost::asio::ip::tcp tcp; 21 | typedef boost::asio::ip::udp udp; 22 | typedef p2engine::error_code error_code; 23 | 24 | } 25 | 26 | #endif // utility_h__ 27 | -------------------------------------------------------------------------------- /src/lib/natpunch/auto_mapping.h: -------------------------------------------------------------------------------- 1 | #ifndef UPNP_AUTO_MAPPING_H__ 2 | #define UPNP_AUTO_MAPPING_H__ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace natpunch { 11 | 12 | void start_auto_mapping(p2engine::io_service&); 13 | std::pair get_udp_mapping(); 14 | std::pair get_tcp_mapping(); 15 | 16 | } // namespace natpunch 17 | 18 | #endif // UPNP_AUTO_MAPPING_H__ 19 | -------------------------------------------------------------------------------- /src/lib/natpunch/natpunch.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/natpunch/port_mapping.h: -------------------------------------------------------------------------------- 1 | #ifndef UPNP_UPNPCFG_H__ 2 | #define UPNP_UPNPCFG_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | namespace natpunch { 13 | enum protocol_type { 14 | UDP_MAPPING = 0, 15 | TCP_MAPPING = 1 16 | }; 17 | 18 | struct port_mapping { 19 | port_mapping(int internalPort, protocol_type protocolType) 20 | : internal_port(internalPort), 21 | external_port(internalPort), 22 | protocol(protocolType), 23 | enabled(false) 24 | {} 25 | 26 | port_mapping(int internalPort, int externalPort, protocol_type protocol) 27 | : internal_port(internalPort), 28 | external_port(externalPort), 29 | protocol(protocol), 30 | enabled(false) 31 | {} 32 | 33 | port_mapping() 34 | :enabled(false) 35 | { 36 | } 37 | 38 | boost::asio::ip::address address; 39 | int internal_port; 40 | int external_port; 41 | protocol_type protocol; 42 | bool enabled; 43 | }; 44 | 45 | typedef boost::function natpunch_callback; 46 | 47 | } // namespace natpunch 48 | 49 | #endif // UPNP_UPNPCFG_H__ 50 | -------------------------------------------------------------------------------- /src/lib/natpunch/src/auto_mapping.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/natpunch/src/auto_mapping.cpp -------------------------------------------------------------------------------- /src/lib/p2engine/CMakeList.txt: -------------------------------------------------------------------------------- 1 | make_project( p2engine) -------------------------------------------------------------------------------- /src/lib/p2engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | make_library(p2engine) -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/atomic.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // atomic.hpp 3 | // ~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008-2010 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | #ifndef BOOST_NETWORK_ATOMIC_HPP 11 | #define BOOST_NETWORK_ATOMIC_HPP 12 | 13 | #if !defined(P2ENGINE_HAS_STD_ATOMIC) 14 | # if !defined(P2ENGINE_DISABLE_STD_ATOMIC) 15 | # if defined(P2ENGINE_HAS_CLANG_LIBCXX) 16 | # define P2ENGINE_HAS_STD_ATOMIC 1 17 | # endif // defined(P2ENGINE_HAS_CLANG_LIBCXX) 18 | # if defined(__GNUC__) 19 | # if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4) 20 | # if defined(__GXX_EXPERIMENTAL_CXX0X__) 21 | # define P2ENGINE_HAS_STD_ATOMIC 1 22 | # endif // defined(__GXX_EXPERIMENTAL_CXX0X__) 23 | # endif // ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ > 4) 24 | # endif // defined(__GNUC__) 25 | # if defined(_MSC_VER) 26 | # if (_MSC_VER >= 1700) 27 | # define P2ENGINE_HAS_STD_ATOMIC 1 28 | # endif // (_MSC_VER >= 1700) 29 | # endif // defined(P2ENGINE_MSVC) 30 | # endif // !defined(P2ENGINE_DISABLE_STD_ATOMIC) 31 | #endif // !defined(P2ENGINE_HAS_STD_ATOMIC) 32 | 33 | #ifdef P2ENGINE_HAS_STD_ATOMIC 34 | #include 35 | #define CXX11_ATOMIC std 36 | #else 37 | #include 38 | #define CXX11_ATOMIC boost 39 | #endif 40 | #include 41 | namespace p2engine{ 42 | using CXX11_ATOMIC::atomic; 43 | using CXX11_ATOMIC::atomic_int; 44 | using CXX11_ATOMIC::atomic_flag; 45 | 46 | using CXX11_ATOMIC::atomic_thread_fence; 47 | using CXX11_ATOMIC::memory_order_relaxed; 48 | using CXX11_ATOMIC::memory_order_acquire; 49 | using CXX11_ATOMIC::memory_order_release; 50 | using CXX11_ATOMIC::memory_order_acq_rel; 51 | using CXX11_ATOMIC::memory_order_consume; 52 | using CXX11_ATOMIC::memory_order_seq_cst; 53 | } 54 | 55 | #endif//p2engine_atomic_hpp__ 56 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/basic_engine_object.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // basic_engine_object.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef P2ENGINE_BASIC_ENGINE_OBJECT_HPP 20 | #define P2ENGINE_BASIC_ENGINE_OBJECT_HPP 21 | 22 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 23 | # pragma once 24 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 25 | 26 | #include 27 | 28 | #include "p2engine/basic_object.hpp" 29 | 30 | namespace p2engine { 31 | 32 | class basic_engine_object 33 | : public basic_object 34 | { 35 | typedef basic_engine_object this_type; 36 | SHARED_ACCESS_DECLARE; 37 | 38 | public: 39 | typedef asio::io_service io_service; 40 | typedef boost::thread::id thread_id; 41 | 42 | protected: 43 | basic_engine_object(io_service& iosvc) 44 | : io_service_(iosvc) 45 | { 46 | } 47 | 48 | public: 49 | io_service& get_io_service() 50 | { 51 | return io_service_; 52 | } 53 | 54 | private: 55 | io_service& io_service_; 56 | }; 57 | 58 | PTR_TYPE_DECLARE(basic_engine_object); 59 | 60 | } // namespace p2engine 61 | 62 | #endif // P2ENGINE_BASIC_ENGINE_OBJECT_HPP 63 | 64 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/compressed_bitset.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/p2engine/compressed_bitset.hpp -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/config/function.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2009, GuangZhu Wu 3 | // 4 | //This program is free software; you can redistribute it and/or modify it 5 | //under the terms of the GNU General Public License or any later version. 6 | // 7 | //This program is distributed in the hope that it will be useful, but 8 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 9 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10 | //for more details. 11 | // 12 | //You should have received a copy of the GNU General Public License along 13 | //with this program; if not, contact . 14 | // 15 | #ifndef P2ENGINE_CONFIG_FUNCTION_HPP 16 | #define P2ENGINE_CONFIG_FUNCTION_HPP 17 | #if defined(P2ENGINE_HAS_STD_FUNCTION) 18 | # include 19 | namespace p2engine{ 20 | using std::function; 21 | using std::bind; 22 | } 23 | #else // defined(P2ENGINE_HAS_STD_FUNCTION) 24 | # include 25 | # include 26 | namespace p2engine{ 27 | using boost::function; 28 | using boost::bind; 29 | } 30 | #endif // defined(P2ENGINE_HAS_STD_FUNCTION) 31 | 32 | #endif//P2ENGINE_CONFIG_FUNCTION_HPP 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/fast_stl.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // fast_stl.hpp 3 | // ~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008-2010 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | #ifndef P2ENGINE_FAST_STL_HPP 11 | #define P2ENGINE_FAST_STL_HPP 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | namespace p2engine{ 20 | 21 | template > 22 | class fast_set 23 | :public boost::multi_index::multi_index_container< 24 | Key, 25 | boost::multi_index::indexed_by< boost::multi_index::ordered_unique< 26 | boost::multi_index::identity, Compare 27 | > > 28 | > 29 | { 30 | public: 31 | typedef Key key_type; 32 | typedef Compare key_compare; 33 | }; 34 | 35 | } 36 | 37 | #endif//P2ENGINE_FAST_STL_HPP 38 | 39 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/file/aiofile.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // aiofile.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef AIOFILE_AIOFILE_HPP 20 | #define AIOFILE_AIOFILE_HPP 21 | 22 | #include "p2engine/file/file_api.hpp" 23 | #include "p2engine/file/basic_aiofile.hpp" 24 | 25 | #ifndef AIOFILE_NORMAL 26 | 27 | # ifdef WIN32 28 | # if !defined(BOOST_ASIO_DISABLE_IOCP) 29 | # define AIOFILE_IOCP 30 | # else 31 | # define AIOFILE_NORMAL 32 | # endif//!defined(BOOST_ASIO_DISABLE_IOCP) 33 | # endif//ifdef WIN32 34 | 35 | # if !defined(AIOFILE_IOCP)&&!defined(AIOFILE_POSIX_AIO) 36 | # define AIOFILE_NORMAL 37 | # endif//if !defined(AIOFILE_IOCP)&&!defined(AIOFILE_POSIX_AIO) 38 | 39 | #endif 40 | 41 | 42 | #ifdef AIOFILE_IOCP 43 | # include "p2engine/file/win_aiofile_service.hpp" 44 | namespace p2engine{ 45 | typedef basic_aiofile aiofile; 46 | } 47 | 48 | #elif defined AIOFILE_POSIX_AIO 49 | # error AIOFILE_ENABLE_POSIX_AIO NOT IMP 50 | 51 | 52 | #else 53 | # include "p2engine/file/normal_aiofile_service.hpp" 54 | namespace p2engine{ 55 | typedef basic_aiofile aiofile; 56 | } 57 | 58 | #endif 59 | 60 | 61 | 62 | #endif//AIOFILE_AIOFILE_HPP 63 | 64 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/file/posix_aiofile_service.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // posix_aiofile_service.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef AIOFILE_IMPL_POSIX_AIOFILE_HPP 20 | #define AIOFILE_IMPL_POSIX_AIOFILE_HPP 21 | 22 | #ifdef AIOFILE_POSIX_AIO 23 | 24 | #include "p2engine/file/file_api.hpp" 25 | #include "p2engine/file/faio_service.hpp" 26 | #include "p2engine/atomic.hpp" 27 | #include "p2engine/wrappable_integer.hpp" 28 | 29 | namespace p2engine{ 30 | 31 | } 32 | 33 | #endif //AIOFILE_POSIX_AIO 34 | 35 | #endif// AIOFILE_IMPL_POSIX_AIOFILE_HPP 36 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/get_derived_this.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // get_derived_this.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef P2ENGINE_GET_DERIVED_THIS_HPP 20 | #define P2ENGINE_GET_DERIVED_THIS_HPP 21 | 22 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 23 | # pragma once 24 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 25 | 26 | #include "p2engine/push_warning_option.hpp" 27 | #include "p2engine/config.hpp" 28 | #include "p2engine/utilities.hpp" 29 | 30 | namespace p2engine{ 31 | 32 | template 33 | struct get_derived_this 34 | { 35 | BOOST_STATIC_ASSERT((boost::is_base_and_derived::value)); 36 | Derived* operator()(Base* ptr)const 37 | { 38 | Derived*p=(Derived*)(ptr);//!!DO NOT USING reinterpret_cast!! 39 | BOOST_ASSERT((uintptr_t)dynamic_cast(ptr)==(uintptr_t)(p)); 40 | return p; 41 | } 42 | }; 43 | 44 | } 45 | 46 | #endif // P2ENGINE_GET_DERIVED_THIS_HPP 47 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/http/header.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/p2engine/http/header.hpp -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/http/http.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // http.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef P2ENGINE_Http_h__ 20 | #define P2ENGINE_Http_h__ 21 | 22 | #include "p2engine/http/request.hpp" 23 | #include "p2engine/http/response.hpp" 24 | #include "p2engine/http/mime_types.hpp" 25 | #include "p2engine/http/http_connection.hpp" 26 | #include "p2engine/http/http_acceptor.hpp" 27 | #include "p2engine/gzip.hpp" 28 | 29 | namespace p2engine{ namespace http{ 30 | 31 | #define HTTP_DECLARE(connectionName, acceptorName)\ 32 | typedef basic_http_connection http_##connectionName;\ 33 | typedef basic_http_acceptor http_##acceptorName;\ 34 | PTR_TYPE_DECLARE(connectionName);\ 35 | PTR_TYPE_DECLARE(acceptorName);\ 36 | PTR_TYPE_DECLARE(http_##connectionName);\ 37 | PTR_TYPE_DECLARE(http_##acceptorName); 38 | 39 | typedef basic_http_connection http_connection; 40 | typedef basic_http_acceptor http_acceptor; 41 | } 42 | } 43 | 44 | #endif//P2ENGINE_Http_h__ 45 | 46 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/http/http_acceptor_base.hpp: -------------------------------------------------------------------------------- 1 | #ifndef P2ENGINE_HTTP_ACCEPTOR_BASE_HPP 2 | #define P2ENGINE_HTTP_ACCEPTOR_BASE_HPP 3 | 4 | #include "p2engine/config.hpp" 5 | #include "p2engine/time.hpp" 6 | #include "p2engine/basic_dispatcher.hpp" 7 | #include "p2engine/basic_engine_object.hpp" 8 | //#include "p2engine/fssignal.hpp" 9 | #include "p2engine/variant_endpoint.hpp" 10 | #include "p2engine/contrib.hpp" 11 | 12 | #include "p2engine/http/response.hpp" 13 | #include "p2engine/http/request.hpp" 14 | #include "p2engine/http/basic_http_dispatcher.hpp" 15 | 16 | namespace p2engine { namespace http { 17 | 18 | template 19 | class http_acceptor_base 20 | :public basic_engine_object 21 | , public basic_http_acceptor_dispatcher 22 | { 23 | typedef http_acceptor_base this_type; 24 | SHARED_ACCESS_DECLARE; 25 | 26 | public: 27 | typedef ConnectionBaseType connection_base_type; 28 | typedef tcp::acceptor lowest_layer_type; 29 | 30 | protected: 31 | http_acceptor_base(io_service&ios) 32 | :basic_engine_object(ios) 33 | {} 34 | virtual ~http_acceptor_base(){}; 35 | 36 | public: 37 | virtual error_code open(const endpoint& local_edp, error_code& ec)=0; 38 | 39 | virtual error_code listen(error_code& ec)=0; 40 | 41 | virtual error_code listen(const endpoint& local_edp, error_code& ec)=0; 42 | 43 | template 44 | void set_option(const Option& option, error_code& ec) 45 | { 46 | this->lowest_layer().set_option(option, ec); 47 | } 48 | 49 | virtual void keep_async_accepting()=0; 50 | virtual void block_async_accepting()=0; 51 | 52 | error_code close(){error_code ec; return close(ec);} 53 | virtual error_code close(error_code& ec)=0; 54 | virtual bool is_open()const=0; 55 | 56 | virtual lowest_layer_type& lowest_layer()=0; 57 | 58 | virtual endpoint local_endpoint(error_code& ec) const=0; 59 | 60 | }; 61 | 62 | 63 | } // namespace http 64 | } // namespace p2engine 65 | 66 | #endif // P2ENGINE_HTTP_CONNECTION_BASE_HPP 67 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/http/mime_types.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // mime_types.hpp 3 | // ~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef HTTP_P2ENGINE_MIME_TYPES_HPP 12 | #define HTTP_P2ENGINE_MIME_TYPES_HPP 13 | 14 | #include "p2engine/config.hpp" 15 | 16 | namespace p2engine { 17 | namespace http { 18 | namespace mime_types { 19 | 20 | // Map the file name extension to MIME type. 21 | const char* ext_to_mime(const char* ext_name); 22 | 23 | // Map the file name extension to MIME type. 24 | const char* mime_to_ext(const char* mime); 25 | 26 | } // namespace mime_types 27 | } // namespace http 28 | } // namespace p2engine 29 | 30 | #endif // HTTP_P2ENGINE_MIME_TYPES_HPP 31 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/http/response.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/p2engine/http/response.hpp -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/logging.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/p2engine/logging.hpp -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/object_allocator.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // object_allocator.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | // 19 | // THANKS Meng Zhang 20 | // 21 | 22 | #ifndef P2ENGINE_OBJECT_ALLOCATOR_HPP 23 | #define P2ENGINE_OBJECT_ALLOCATOR_HPP 24 | 25 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 26 | # pragma once 27 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 28 | 29 | #include "p2engine/basic_object_allocator.hpp" 30 | 31 | namespace p2engine { 32 | 33 | typedef basic_object_allocator<> object_allocator; 34 | } // namespace p2engine 35 | 36 | 37 | #endif // P2ENGINE_MEMORY_POOL_HPP 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/p2engine.hpp: -------------------------------------------------------------------------------- 1 | // p2engine.hpp 2 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 | // 4 | // Copyright (c) 2009-2010 GuangZhu Wu 5 | // 6 | //This program is free software; you can redistribute it and/or modify it 7 | //under the terms of the GNU General Public License or any later version. 8 | // 9 | //This program is distributed in the hope that it will be useful, but 10 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 | //for more details. 13 | // 14 | //You should have received a copy of the GNU General Public License along 15 | //with this program; if not, contact . 16 | // 17 | // 18 | #ifndef P2ENGINE_HPP__ 19 | #define P2ENGINE_HPP__ 20 | 21 | #include "p2engine/config.hpp" 22 | 23 | #include 24 | 25 | #include "p2engine/typedef.hpp" 26 | #include "p2engine/handler_allocator.hpp" 27 | #include "p2engine/basic_engine_object.hpp" 28 | #include "p2engine/socket_utility.hpp" 29 | #include "p2engine/shared_access.hpp" 30 | #include "p2engine/coroutine.hpp" 31 | #include "p2engine/packet_format_def.hpp" 32 | #include "p2engine/packet.hpp" 33 | #include "p2engine/compressed_bitset.hpp" 34 | #include "p2engine/wrappable_integer.hpp" 35 | #include "p2engine/variant_endpoint.hpp" 36 | #include "p2engine/local_id_allocator.hpp" 37 | #include "p2engine/keeper.hpp" 38 | #include "p2engine/speed_meter.hpp" 39 | #include "p2engine/timer.hpp" 40 | #include "p2engine/rdp.hpp" 41 | #include "p2engine/trafic_statistics.hpp" 42 | #include "p2engine/running_service.hpp" 43 | #include "p2engine/enum_net.hpp" 44 | #include "p2engine/broadcast_socket.hpp" 45 | #include "p2engine/post_in_constructor.hpp" 46 | #include "p2engine/http/http.hpp" 47 | #include "p2engine/file/aiofile.hpp" 48 | 49 | #endif//P2ENGINE_HPP__ 50 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/pop_warning_option.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // abi_suffix.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #if defined(_MSC_VER) 20 | # pragma warning (pop) 21 | #endif // defined(_MSC_VER) 22 | 23 | #if defined(__GNUC__) 24 | # if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) 25 | # pragma GCC visibility pop 26 | # endif // (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) 27 | #endif // defined(__GNUC__) 28 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/post_in_constructor.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // post_in_constructor.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef post_in_constructor_h__ 20 | #define post_in_constructor_h__ 21 | 22 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 23 | # pragma once 24 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 25 | 26 | #include "p2engine/intrusive_ptr_base.hpp" 27 | //#include "p2engine/fssignal.hpp" 28 | 29 | namespace p2engine{ 30 | 31 | class post_in_constructor 32 | { 33 | struct post_in_constructor_impl 34 | :public basic_intrusive_ptr 35 | { 36 | void emit(boost::function exec) 37 | { 38 | exec(); 39 | } 40 | }; 41 | public: 42 | post_in_constructor(io_service& ios) 43 | :ios_(ios), impl_(new post_in_constructor_impl) 44 | { 45 | } 46 | void post(boost::function exec) 47 | { 48 | ios_.post(make_alloc_handler(boost::bind(&post_in_constructor_impl::emit, impl_, exec))); 49 | } 50 | private: 51 | io_service& ios_; 52 | boost::intrusive_ptr impl_; 53 | }; 54 | } 55 | 56 | 57 | #endif // post_in_constructor_h__ 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/puff.hpp: -------------------------------------------------------------------------------- 1 | /* puff.h 2 | Copyright (C) 2002, 2003 Mark Adler, all rights reserved 3 | version 1.7, 3 Mar 2002 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the author be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | Mark Adler madler@alumni.caltech.edu 22 | */ 23 | 24 | 25 | /* 26 | * See puff.c for purpose and usage. 27 | */ 28 | #include 29 | 30 | int puff(unsigned char *dest, /* pointer to destination pointer */ 31 | boost::uint32_t *destlen, /* amount of output space */ 32 | unsigned char *source, /* pointer to source data pointer */ 33 | boost::uint32_t *sourcelen); /* amount of input available */ 34 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/push_warning_option.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // push_warning_option.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | // Disable some pesky MSVC warnings. 20 | #if defined(_MSC_VER) 21 | # pragma warning(disable : 4503) 22 | # pragma warning (push) 23 | # pragma warning(disable : 4127) 24 | # pragma warning(disable : 4244) 25 | # pragma warning(disable : 4251) 26 | # pragma warning(disable : 4309) 27 | # pragma warning(disable : 4307) 28 | # pragma warning(disable : 4333) 29 | # pragma warning(disable : 4355) 30 | # pragma warning(disable : 4512) 31 | # pragma warning(disable : 4800) 32 | # pragma warning(disable : 4819) 33 | # pragma warning(disable : 4996) 34 | 35 | # ifndef _CRT_SECURE_NO_WARNINGS 36 | # define _CRT_SECURE_NO_WARNINGS 37 | # endif 38 | # ifndef _SCL_SECURE_NO_WARNINGS 39 | # define _SCL_SECURE_NO_WARNINGS 40 | # endif 41 | #endif // defined(_MSC_VER) 42 | 43 | // Force external visibility of all types. 44 | #if defined(__GNUC__) 45 | # if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) 46 | # pragma GCC visibility push (default) 47 | # endif // (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) 48 | #endif // defined(__GNUC__) 49 | 50 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/rdp/const_define.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // const_define.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef p2engine_rdp_const_define_h__ 20 | #define p2engine_rdp_const_define_h__ 21 | 22 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 23 | # pragma once 24 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 25 | 26 | #include "p2engine/push_warning_option.hpp" 27 | #include 28 | #include "p2engine/pop_warning_option.hpp" 29 | 30 | namespace p2engine{ 31 | 32 | static const uint32_t INVALID_FLOWID = (uint32_t)(-1); 33 | static const uint16_t INVALID_MSGTYPE=(uint16_t)(-1); 34 | static const std::size_t MTU_SIZE=1450; 35 | 36 | } 37 | 38 | #endif//p2engine_rdp_h__ 39 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/rdp/urdp_flow.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/p2engine/rdp/urdp_flow.hpp -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/spinlock.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // spinlock.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | #ifdef _MSC_VER 19 | # pragma once 20 | #endif 21 | 22 | #ifndef _BD_SPINLOCK_H__ 23 | #define _BD_SPINLOCK_H__ 24 | 25 | #include 26 | #include 27 | 28 | #include "p2engine/atomic.hpp" 29 | #include "p2engine/time.hpp" 30 | 31 | namespace p2engine{ 32 | 33 | class spinlock { 34 | public: 35 | typedef boost::asio::detail::scoped_lock scoped_lock; 36 | 37 | spinlock() : locked_(false) {} 38 | 39 | inline bool try_lock() 40 | { 41 | return locked_.exchange(true, memory_order_acquire) == false; 42 | } 43 | 44 | void lock() 45 | { 46 | for (size_t i = 0; !try_lock(); ++i) 47 | { 48 | if (i > 4) 49 | { 50 | if (i >= 20 && (i & 4) == 0) 51 | system_time::sleep_millisec(0); 52 | else 53 | boost::this_thread::yield(); 54 | } 55 | } 56 | } 57 | void unlock() 58 | { 59 | locked_.store(false, memory_order_release); 60 | } 61 | 62 | private: 63 | atomic locked_; 64 | }; 65 | 66 | } 67 | 68 | 69 | 70 | #endif//_BD_SPINLOCK_H__ -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/type_traits.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // type_traits.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | # ifndef P2ENGINE_DETAIL_IS_XXX__HPP 20 | # define P2ENGINE_DETAIL_IS_XXX__HPP 21 | 22 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 23 | # pragma once 24 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 25 | 26 | #include "p2engine/push_warning_option.hpp" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | #include 35 | 36 | namespace p2engine { namespace detail{ 37 | 38 | namespace mpl=boost::mpl; 39 | 40 | BOOST_DETAIL_IS_XXX_DEF(shared_ptr, boost::shared_ptr, 1); 41 | BOOST_DETAIL_IS_XXX_DEF(weak_ptr, boost::weak_ptr, 1); 42 | BOOST_DETAIL_IS_XXX_DEF(intrusive_ptr, boost::intrusive_ptr, 1); 43 | BOOST_DETAIL_IS_XXX_DEF(scoped_ptr, boost::scoped_ptr, 1); 44 | 45 | //auto_ptr 46 | #ifndef BOOST_NO_AUTO_PTR 47 | BOOST_DETAIL_IS_XXX_DEF(auto_ptr, std::auto_ptr, 1); 48 | #endif 49 | 50 | //tr1 51 | #ifdef BOOST_HAS_TR1_SHARED_PTR 52 | BOOST_DETAIL_IS_XXX_DEF(shared_ptr, std::tr1::shared_ptr, 1); 53 | BOOST_DETAIL_IS_XXX_DEF(weak_ptr, std::tr1::weak_ptr, 1); 54 | #endif 55 | 56 | } 57 | } 58 | 59 | #include "p2engine/pop_warning_option.hpp" 60 | 61 | #endif // P2ENGINE_DETAIL_IS_XXX__HPP 62 | -------------------------------------------------------------------------------- /src/lib/p2engine/p2engine/utf8.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // utf8.hpp 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2009, GuangZhu Wu 6 | // 7 | //This program is free software; you can redistribute it and/or modify it 8 | //under the terms of the GNU General Public License or any later version. 9 | // 10 | //This program is distributed in the hope that it will be useful, but 11 | //WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | //or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 | //for more details. 14 | // 15 | //You should have received a copy of the GNU General Public License along 16 | //with this program; if not, contact . 17 | // 18 | 19 | #ifndef p2engine_utf8_hpp__ 20 | #define p2engine_utf8_hpp__ 21 | 22 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 23 | # pragma once 24 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 25 | 26 | #include 27 | 28 | namespace p2engine { 29 | 30 | #ifndef P2ENGINE_NO_WIDE_FUNCTIONS 31 | int utf8_wchar(const std::string &utf8, std::wstring &wide); 32 | int wchar_utf8(const std::wstring &wide, std::string &utf8); 33 | std::wstring convert_to_wstring(std::string const& s); 34 | std::string convert_from_wstring(std::wstring const& s); 35 | #endif 36 | 37 | std::string convert_to_native(std::string const& s); 38 | std::string convert_from_native(std::string const& s); 39 | 40 | } 41 | 42 | #endif//p2engine_utf8_hpp__ 43 | 44 | -------------------------------------------------------------------------------- /src/lib/p2engine/src/basic_dispatcher.cpp: -------------------------------------------------------------------------------- 1 | #include "p2engine/basic_dispatcher.hpp" 2 | 3 | NAMESPACE_BEGIN(p2engine) 4 | 5 | basic_connection_dispatcher::received_handle_type 6 | basic_connection_dispatcher::s_msg_handler_; 7 | 8 | NAMESPACE_END(p2engine) 9 | -------------------------------------------------------------------------------- /src/lib/p2engine/src/http/basic_http_dispatcher.cpp: -------------------------------------------------------------------------------- 1 | #include "p2engine/http/basic_http_dispatcher.hpp" 2 | 3 | #include "p2engine/http/request.hpp" 4 | #include "p2engine/http/response.hpp" 5 | 6 | namespace p2engine { namespace http { 7 | 8 | http_connection_dispatcher::received_request_handler_type http_connection_dispatcher::s_request_handler_; 9 | http_connection_dispatcher::received_response_handler_type http_connection_dispatcher::s_response_handler_; 10 | 11 | bool http_connection_dispatcher::dispatch_request(request& buf) 12 | { 13 | //1. search bind in this socket 14 | if (!request_handler_.empty()) 15 | { 16 | request_handler_(buf); 17 | return true; 18 | } 19 | 20 | //2. search bind in all socket 21 | if (!s_request_handler_.empty()) 22 | { 23 | s_request_handler_(buf); 24 | return true; 25 | } 26 | 27 | //3. not find, alert error 28 | BOOST_ASSERT(0&&"can't find message dispatch_packet slot"); 29 | LOG(LogError("can't find message dispath slot");); 30 | return false; 31 | } 32 | bool http_connection_dispatcher::dispatch_response(response& buf) 33 | { 34 | //1. search bind in this socket 35 | if (!response_handler_.empty()) 36 | { 37 | response_handler_(buf); 38 | return true; 39 | } 40 | 41 | //2. search bind in all socket 42 | if (!s_response_handler_.empty()) 43 | { 44 | s_response_handler_(buf); 45 | return true; 46 | } 47 | 48 | //3. not find, alert error 49 | BOOST_ASSERT(0&&"can't find message dispatch_packet slot"); 50 | LOG(LogError("can't find message dispath slot")); 51 | return false; 52 | } 53 | 54 | } 55 | } -------------------------------------------------------------------------------- /src/lib/p2engine/src/http/header.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/src/http/header.cpp -------------------------------------------------------------------------------- /src/lib/p2engine/src/http/response.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/src/http/response.cpp -------------------------------------------------------------------------------- /src/lib/p2engine/src/logging.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/src/logging.cpp -------------------------------------------------------------------------------- /src/lib/p2engine/src/rdp/basic_shared_udp_layer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/src/rdp/basic_shared_udp_layer.cpp -------------------------------------------------------------------------------- /src/lib/p2engine/src/rdp/rdp.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/src/rdp/rdp.rar -------------------------------------------------------------------------------- /src/lib/p2engine/src/rdp/urdp_flow.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/p2engine/src/rdp/urdp_flow.cpp -------------------------------------------------------------------------------- /src/lib/server/CMakeList.txt: -------------------------------------------------------------------------------- 1 | make_project( server) -------------------------------------------------------------------------------- /src/lib/server/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | make_library(server) -------------------------------------------------------------------------------- /src/lib/server/config.h: -------------------------------------------------------------------------------- 1 | // 2 | // config.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | #ifndef server_config_h__ 10 | #define server_config_h__ 11 | 12 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 13 | # pragma once 14 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | 16 | #include "common/common.h" 17 | #include "simple_server/simple_distributor.h" 18 | 19 | namespace p2server{ 20 | using namespace p2engine; 21 | using namespace p2common; 22 | using namespace p2simple; 23 | using namespace asfio; 24 | 25 | class basic_server_object 26 | { 27 | public: 28 | basic_server_object(const server_param_sptr& param) 29 | :server_param_(param) 30 | { 31 | } 32 | virtual ~basic_server_object() 33 | { 34 | } 35 | server_param_sptr& get_server_param_sptr() 36 | { 37 | return server_param_; 38 | } 39 | const server_param_sptr& get_server_param_sptr()const 40 | { 41 | return server_param_; 42 | } 43 | protected: 44 | server_param_sptr server_param_; 45 | }; 46 | } 47 | 48 | #endif//server_typedef_h__ 49 | -------------------------------------------------------------------------------- /src/lib/server/media_distributor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/server/media_distributor.cpp -------------------------------------------------------------------------------- /src/lib/server/media_distributor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/server/media_distributor.h -------------------------------------------------------------------------------- /src/lib/server/seed_connection.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/server/seed_connection.cpp -------------------------------------------------------------------------------- /src/lib/server/server.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/lib/server/server.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | 6 | -------------------------------------------------------------------------------- /src/lib/server/server_service.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/server/server_service.cpp -------------------------------------------------------------------------------- /src/lib/server/server_service.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/server/server_service.h -------------------------------------------------------------------------------- /src/lib/server/server_service_logic.h: -------------------------------------------------------------------------------- 1 | // 2 | // server_service_logic.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | #ifndef server_server_service_logic_h__ 10 | #define server_server_service_logic_h__ 11 | 12 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 13 | # pragma once 14 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | 16 | #include "server/server_service.h" 17 | 18 | namespace p2server 19 | { 20 | typedef server_service server_service_logic_base; 21 | } 22 | 23 | #endif//server_server_service_logic_h__ -------------------------------------------------------------------------------- /src/lib/server/tracker_session.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/server/tracker_session.cpp -------------------------------------------------------------------------------- /src/lib/server/tracker_session.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/server/tracker_session.h -------------------------------------------------------------------------------- /src/lib/shunt/config.h: -------------------------------------------------------------------------------- 1 | // 2 | // config.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | #ifndef shunt_config_h__ 10 | #define shunt_config_h__ 11 | 12 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 13 | # pragma once 14 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | 16 | #include "common/common.h" 17 | #include "client/client_service_logic.h" 18 | #include "server/server_service_logic.h" 19 | #include "tracker/tracker_service_logic.h" 20 | 21 | namespace p2shunt{ 22 | using namespace p2engine; 23 | 24 | extern const std::string default_channel_key; 25 | extern const std::string default_channel_uuid; 26 | } 27 | 28 | #endif//shunt_config_h__ 29 | -------------------------------------------------------------------------------- /src/lib/shunt/creator.cpp: -------------------------------------------------------------------------------- 1 | #include "shunt/creator.h" 2 | #include "shunt/fluid_receiver.h" 3 | #include "shunt/media_receiver.h" 4 | #include "shunt/fluid_sender.h" 5 | #include "shunt/media_sender.h" 6 | 7 | NAMESPACE_BEGIN(p2shunt); 8 | 9 | boost::shared_ptr receiver_creator::create(const std::string& url, 10 | io_service& ios, bool usevlc) 11 | { 12 | error_code ec; 13 | uri u(url, ec); 14 | if (ec) 15 | return boost::shared_ptr(); 16 | 17 | if (usevlc) 18 | { 19 | return vlc_fluid_receiver::create(ios); 20 | } 21 | else if ("udp" == u.protocol()) 22 | { 23 | if (is_multicast(endpoint_from_string(u.host()).address())) 24 | return multicast_fluid_receiver::create(ios); 25 | else 26 | return unicast_fluid_receiver::create(ios); 27 | } 28 | else if ("http" == u.protocol()) 29 | { 30 | return http_fluid_receiver::create(ios); 31 | } 32 | else if ("shunt" == u.protocol()) 33 | { 34 | return media_receiver::create(ios); 35 | } 36 | return boost::shared_ptr(); 37 | } 38 | 39 | boost::shared_ptr sender_creator::create( 40 | const std::string& url, io_service& ios) 41 | { 42 | error_code ec; 43 | uri u(url, ec); 44 | if (ec) 45 | return boost::shared_ptr(); 46 | 47 | if ("udp" == u.protocol()) 48 | { 49 | return udp_fluid_sender::create(ios); 50 | } 51 | else if ("http" == u.protocol()) 52 | { 53 | return http_fluid_sender::create(ios); 54 | } 55 | else if ("shunt" == u.protocol()) 56 | { 57 | return media_sender::create(ios); 58 | } 59 | 60 | return boost::shared_ptr(); 61 | } 62 | 63 | NAMESPACE_END(p2shunt); -------------------------------------------------------------------------------- /src/lib/shunt/creator.h: -------------------------------------------------------------------------------- 1 | #ifndef p2s_p2p_shunt_creator_h__ 2 | #define p2s_p2p_shunt_creator_h__ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace p2engine; 9 | 10 | namespace p2shunt 11 | { 12 | class receiver; 13 | class sender; 14 | 15 | struct receiver_creator 16 | { 17 | static boost::shared_ptr create(const std::string& url, 18 | io_service& ios, bool usevlc=false); 19 | }; 20 | 21 | struct sender_creator 22 | { 23 | static boost::shared_ptr create(const std::string& url, 24 | io_service& ios); 25 | }; 26 | }; 27 | 28 | #endif // p2s_p2p_shunt_creator_h__ 29 | -------------------------------------------------------------------------------- /src/lib/shunt/fluid_media_convert.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHUNT_FLUID_TO_MEDIA_H__ 2 | #define _SHUNT_FLUID_TO_MEDIA_H__ 3 | 4 | #include "common/common.h" 5 | 6 | namespace p2shunt{ 7 | using namespace p2engine; 8 | 9 | class fluid_to_media 10 | { 11 | public: 12 | fluid_to_media() 13 | { 14 | seqno_seed_=0; 15 | } 16 | void operator()(const asio::const_buffers_1& in, media_packet& out) 17 | { 18 | out.set_time_stamp(timestamp_now()); 19 | out.set_seqno(seqno_seed_++); 20 | safe_buffer_io io(&out.buffer()); 21 | io.write(asio::buffer_cast(in), asio::buffer_size(in)); 22 | } 23 | void operator()(const safe_buffer& in, media_packet& out) 24 | { 25 | out.set_time_stamp(timestamp_now()); 26 | out.set_seqno(seqno_seed_++); 27 | safe_buffer_io io(&out.buffer()); 28 | io.write(p2engine::buffer_cast(in), p2engine::buffer_size(in)); 29 | } 30 | protected: 31 | seqno_t seqno_seed_; 32 | }; 33 | 34 | class media_to_fluid 35 | { 36 | public: 37 | void operator()(const media_packet& in, safe_buffer& out) 38 | { 39 | safe_buffer_io io(&out); 40 | io.write( 41 | p2engine::buffer_cast(in.buffer())+media_packet::format_size(), 42 | in.buffer().length()-media_packet::format_size() 43 | ); 44 | } 45 | }; 46 | 47 | } 48 | 49 | #endif//_SHUNT_FLUID_TO_MEDIA_H__ 50 | 51 | -------------------------------------------------------------------------------- /src/lib/shunt/fluid_receiver.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/fluid_receiver.cpp -------------------------------------------------------------------------------- /src/lib/shunt/fluid_receiver.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/fluid_receiver.h -------------------------------------------------------------------------------- /src/lib/shunt/fluid_sender.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/fluid_sender.cpp -------------------------------------------------------------------------------- /src/lib/shunt/fluid_sender.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/fluid_sender.h -------------------------------------------------------------------------------- /src/lib/shunt/media_receiver.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/media_receiver.cpp -------------------------------------------------------------------------------- /src/lib/shunt/media_receiver.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHUNT_MEDIA_RECEIVER_H__ 2 | #define _SHUNT_MEDIA_RECEIVER_H__ 3 | 4 | #include "shunt/receiver.h" 5 | 6 | namespace p2shunt{ 7 | using namespace p2client; 8 | 9 | class client_for_receiver; 10 | 11 | class media_receiver 12 | :public receiver 13 | { 14 | typedef media_receiver this_type; 15 | SHARED_ACCESS_DECLARE; 16 | friend class client_for_receiver; 17 | public: 18 | static shared_ptr create(io_service& ios) 19 | { 20 | return shared_ptr(new this_type(ios), 21 | shared_access_destroy()); 22 | } 23 | 24 | virtual void stop(){}; 25 | virtual bool is_connected()const{return is_connected_;}; 26 | virtual bool updata(const std::string& url, error_code& ec); 27 | 28 | void handle_media(const safe_buffer&); 29 | 30 | protected: 31 | media_receiver(io_service& ios); 32 | ~media_receiver(); 33 | 34 | protected: 35 | boost::shared_ptr client_interface_; 36 | variant_endpoint the_edp_; 37 | std::pair key_pair_;// 38 | 39 | bool is_connected_; 40 | }; 41 | } 42 | 43 | #endif//_SHUNT_MEDIA_RECEIVER_H__ 44 | 45 | -------------------------------------------------------------------------------- /src/lib/shunt/media_sender.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/media_sender.cpp -------------------------------------------------------------------------------- /src/lib/shunt/media_sender.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHUNT_MEDIA_SENDER_H__ 2 | #define _SHUNT_MEDIA_SENDER_H__ 3 | 4 | #include "shunt/sender.h" 5 | 6 | namespace p2shunt{ 7 | using namespace p2server; 8 | 9 | class media_sender 10 | :public sender 11 | { 12 | typedef media_sender this_type; 13 | SHARED_ACCESS_DECLARE; 14 | protected: 15 | media_sender(io_service& ios); 16 | virtual ~media_sender(); 17 | 18 | public: 19 | static shared_ptr create(io_service& ios) 20 | { 21 | return shared_ptr(new this_type(ios), 22 | shared_access_destroy() 23 | ); 24 | } 25 | 26 | bool updata(const std::string&url, error_code& ec); 27 | 28 | void shunt(const safe_buffer& pkt); 29 | 30 | private: 31 | boost::shared_ptr server_interface_; 32 | boost::shared_ptr tracker_interface_; 33 | variant_endpoint the_edp_; 34 | variant_endpoint the_extrenal_edp_; 35 | }; 36 | 37 | } 38 | 39 | 40 | #endif // _SHUNT_MEDIA_SENDER_H__ 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/lib/shunt/receiver.h: -------------------------------------------------------------------------------- 1 | #ifndef _SHUNT_RECEIVER_H__ 2 | #define _SHUNT_RECEIVER_H__ 3 | 4 | #include "shunt/config.h" 5 | 6 | namespace p2shunt{ 7 | 8 | class receiver 9 | :public basic_engine_object 10 | { 11 | public: 12 | typedef boost::function media_handler_type; 13 | media_handler_type media_handler; 14 | 15 | public: 16 | virtual void stop()=0; 17 | virtual bool is_connected()const=0; 18 | virtual bool updata(const std::string& edpStr, error_code& ec)=0; 19 | double average_media_speed()//kbps 20 | { 21 | return speed_meter_.bytes_per_second()*8/1024; 22 | } 23 | double average_packet_speed()//packets per second 24 | { 25 | return packet_speed_meter_.bytes_per_second(); 26 | } 27 | double instantaneous_media_speed()//kbps 28 | { 29 | return instantaneous_speed_meter_.bytes_per_second()*8/1024; 30 | } 31 | double instantaneous_packet_speed()//packets per second 32 | { 33 | return instantaneous_packet_speed_meter_.bytes_per_second(); 34 | } 35 | protected: 36 | receiver(io_service& ios) 37 | :basic_engine_object(ios) 38 | , speed_meter_(seconds(15)) 39 | , packet_speed_meter_(seconds(15)) 40 | , instantaneous_speed_meter_(millisec(500)) 41 | , instantaneous_packet_speed_meter_(millisec(500)) 42 | {} 43 | 44 | protected: 45 | rough_speed_meter speed_meter_; 46 | rough_speed_meter packet_speed_meter_; 47 | rough_speed_meter instantaneous_speed_meter_; 48 | rough_speed_meter instantaneous_packet_speed_meter_; 49 | }; 50 | 51 | } 52 | 53 | #endif//_SHUNT_RECEIVER_H__ 54 | 55 | -------------------------------------------------------------------------------- /src/lib/shunt/sender.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/sender.h -------------------------------------------------------------------------------- /src/lib/shunt/shunt.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/lib/shunt/typedef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/shunt/typedef.h -------------------------------------------------------------------------------- /src/lib/simple_server/config.h: -------------------------------------------------------------------------------- 1 | // 2 | // config.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | #ifndef simple_server_config_h__ 10 | #define simple_server_config_h__ 11 | 12 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 13 | # pragma once 14 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | 16 | #include "common/common.h" 17 | 18 | namespace asfio{} 19 | 20 | namespace p2simple{ 21 | using namespace p2engine; 22 | using namespace p2common; 23 | using namespace asfio; 24 | } 25 | 26 | #endif//simple_server_config_h__ 27 | 28 | -------------------------------------------------------------------------------- /src/lib/simple_server/distributor_Impl.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/simple_server/distributor_Impl.hpp -------------------------------------------------------------------------------- /src/lib/simple_server/distributor_scheduling.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/simple_server/distributor_scheduling.cpp -------------------------------------------------------------------------------- /src/lib/simple_server/multi_source_distributor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/simple_server/multi_source_distributor.cpp -------------------------------------------------------------------------------- /src/lib/simple_server/peer_connection.cpp: -------------------------------------------------------------------------------- 1 | #include "simple_server/peer_connection.h" 2 | #include "client/peer.h" 3 | 4 | using namespace p2simple; 5 | 6 | namespace 7 | { 8 | const time_duration MEDIA_CONFIRM_INTERVAL=milliseconds(100); 9 | } 10 | 11 | peer_connection::peer_connection(io_service& ios, bool realTimeUsage, bool isPassive) 12 | :message_socket(ios, realTimeUsage, isPassive) 13 | { 14 | m_last_media_confirm_time=timestamp_now(); 15 | } 16 | 17 | peer_connection::~peer_connection() 18 | { 19 | } 20 | 21 | void peer_connection::piece_confirm(timestamp_t now) 22 | { 23 | if (!is_connected()) 24 | { 25 | return; 26 | } 27 | 28 | int64_t interval=MEDIA_CONFIRM_INTERVAL.total_milliseconds(); 29 | if(!m_media_have_sent.empty()) 30 | { 31 | if (m_media_have_sent.size()>8 32 | ||is_time_passed(interval, m_last_media_confirm_time, now) 33 | ) 34 | { 35 | media_sent_confirm_msg msg; 36 | BOOST_FOREACH(seqno_t seq, m_media_have_sent) 37 | { 38 | msg.add_seqno(seq); 39 | } 40 | async_send_unreliable(serialize(msg), global_msg::media_sent_confirm); 41 | m_media_have_sent.clear(); 42 | m_last_media_confirm_time=now; 43 | } 44 | } 45 | else 46 | { 47 | m_last_media_confirm_time=now; 48 | } 49 | } 50 | 51 | void peer_connection::send_media_packet(const safe_buffer& buf, 52 | seqno_t seqno, timestamp_t now) 53 | { 54 | async_send_unreliable(buf, global_msg::media); 55 | media_have_sent(seqno, now); 56 | } 57 | -------------------------------------------------------------------------------- /src/lib/simple_server/peer_connection.h: -------------------------------------------------------------------------------- 1 | // 2 | // peer_connection.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | #ifndef simple_server_peer_connection_h__ 10 | #define simple_server_peer_connection_h__ 11 | 12 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 13 | # pragma once 14 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | 16 | #include "simple_server/config.h" 17 | #include 18 | #include 19 | #include 20 | 21 | namespace p2simple{ 22 | 23 | class peer_connection 24 | :public message_socket 25 | { 26 | typedef peer_connection this_type; 27 | SHARED_ACCESS_DECLARE; 28 | public: 29 | peer_connection(io_service& ios, bool realTimeUsage, bool isPassive); 30 | virtual ~peer_connection(); 31 | 32 | public: 33 | const std::string& channel_id()const 34 | { 35 | BOOST_ASSERT(!channel_id_.empty()); 36 | return channel_id_; 37 | }; 38 | void channel_id(const std::string& channelID) 39 | { 40 | channel_id_=channelID; 41 | } 42 | void piece_confirmed(timestamp_t now) 43 | { 44 | m_last_media_confirm_time=now; 45 | } 46 | void piece_confirm(timestamp_t now); 47 | 48 | void media_have_sent(seqno_t seqno, timestamp_t now) 49 | { 50 | m_media_have_sent.push_back(seqno); 51 | if (m_media_have_sent.size()>4) 52 | piece_confirm(now); 53 | } 54 | void send_media_packet(const safe_buffer& buf, seqno_t seqno, 55 | timestamp_t now); 56 | 57 | private: 58 | timestamp_t m_last_media_confirm_time; 59 | std::vectorm_media_have_sent; 60 | std::string channel_id_; 61 | }; 62 | 63 | RDP_DECLARE(peer_connection, peer_acceptor); 64 | } 65 | 66 | #endif//simple_server_peer_connection_h__ -------------------------------------------------------------------------------- /src/lib/simple_server/simple_distributor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/simple_server/simple_distributor.cpp -------------------------------------------------------------------------------- /src/lib/simple_server/simple_distributor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/simple_server/simple_distributor.h -------------------------------------------------------------------------------- /src/lib/simple_server/simple_server.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/lib/simple_server/utility.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/simple_server/utility.cpp -------------------------------------------------------------------------------- /src/lib/simple_server/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef simple_server_utility_h__ 2 | #define simple_server_utility_h__ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace p2engine; 13 | 14 | namespace p2simple 15 | { 16 | /////////////////////////////////////////// 17 | typedef boost::tuple tuple_type; 18 | 19 | tuple_type title_match(const std::string& t); 20 | 21 | bool find_assist_file(const boost::filesystem::path& file, 22 | std::vector& files); 23 | } 24 | 25 | #endif // utility_h__ 26 | -------------------------------------------------------------------------------- /src/lib/tracker/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | make_library(tracker) -------------------------------------------------------------------------------- /src/lib/tracker/cache_service.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/cache_service.cpp -------------------------------------------------------------------------------- /src/lib/tracker/cache_service.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/cache_service.h -------------------------------------------------------------------------------- /src/lib/tracker/cache_table.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/cache_table.cpp -------------------------------------------------------------------------------- /src/lib/tracker/cache_table.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/cache_table.h -------------------------------------------------------------------------------- /src/lib/tracker/config.h: -------------------------------------------------------------------------------- 1 | // 2 | // typedef.h 3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2008 GuangZhu Wu (GuangZhuWu@gmail.com) 6 | // 7 | // All rights reserved. 8 | // 9 | #ifndef tracker_typedef_h__ 10 | #define tracker_typedef_h__ 11 | 12 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) 13 | # pragma once 14 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 15 | 16 | #include "common/common.h" 17 | 18 | namespace p2tracker 19 | { 20 | using namespace p2engine; 21 | using namespace p2common; 22 | using namespace p2message; 23 | 24 | class basic_tracker_object 25 | { 26 | public: 27 | basic_tracker_object(const tracker_param_sptr& param) 28 | :tracker_param_(param) 29 | { 30 | } 31 | virtual ~basic_tracker_object() 32 | { 33 | } 34 | tracker_param_sptr& get_tracker_param_sptr() 35 | { 36 | return tracker_param_; 37 | } 38 | const tracker_param_sptr& get_tracker_param_sptr()const 39 | { 40 | return tracker_param_; 41 | } 42 | protected: 43 | tracker_param_sptr tracker_param_; 44 | }; 45 | } 46 | 47 | #endif//tracker_typedef_h__ 48 | -------------------------------------------------------------------------------- /src/lib/tracker/member_service.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/member_service.cpp -------------------------------------------------------------------------------- /src/lib/tracker/member_service.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/member_service.h -------------------------------------------------------------------------------- /src/lib/tracker/member_table.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/member_table.cpp -------------------------------------------------------------------------------- /src/lib/tracker/member_table.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/member_table.h -------------------------------------------------------------------------------- /src/lib/tracker/tracker.csi: -------------------------------------------------------------------------------- 1 | [Version] 2 | 1=#P0#=2008 . 3 | -------------------------------------------------------------------------------- /src/lib/tracker/tracker.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/lib/tracker/tracker_service.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/tracker_service.cpp -------------------------------------------------------------------------------- /src/lib/tracker/tracker_service.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/tracker_service.h -------------------------------------------------------------------------------- /src/lib/tracker/tracker_service_logic.cpp: -------------------------------------------------------------------------------- 1 | #include "tracker/member_service.h" 2 | #include "tracker/tracker_service_logic.h" 3 | #include "tracker/tracker_service.h" 4 | using namespace p2tracker; 5 | 6 | tracker_service_logic_base::tracker_service_logic_base(io_service& svc) 7 | :basic_engine_object(svc) 8 | { 9 | set_obj_desc("tracker_service_logic"); 10 | } 11 | 12 | tracker_service_logic_base::~tracker_service_logic_base() 13 | { 14 | __stop(); 15 | } 16 | 17 | void tracker_service_logic_base::start(const tracker_param_base& param) 18 | { 19 | if (tracker_service_) 20 | return; 21 | tracker_service_=tracker_service::create(get_io_service(), 22 | create_tracker_param_sptr(param) 23 | ); 24 | tracker_service_->start(SHARED_OBJ_FROM_THIS); 25 | } 26 | 27 | void tracker_service_logic_base::__stop() 28 | { 29 | if (tracker_service_) 30 | { 31 | tracker_service_->stop(); 32 | tracker_service_.reset(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/lib/tracker/tracker_service_logic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/tracker/tracker_service_logic.h -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_letv_urls.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _resolve_letv_urls_ 2 | #define _resolve_letv_urls_ 3 | 4 | #include "urlcrack/crack_urls_base.hpp" 5 | #include 6 | namespace urlcrack 7 | { 8 | class letv_crack: public basic_crack 9 | { 10 | typedef letv_crack this_type; 11 | SHARED_ACCESS_DECLARE; 12 | public: 13 | static shared_ptr create(const std::string& _url, io_service& _ios) 14 | { 15 | return shared_ptr(new this_type(_url, _ios), 16 | shared_access_destroy()); 17 | } 18 | virtual void get_crack_urls(); 19 | protected: 20 | letv_crack(const std::string& _url, io_service& _ios); 21 | ~letv_crack(){}; 22 | void get_vid(const std::string& _content); 23 | void get_crack_urls(const std::string& _strvid); 24 | void get_containurl_url(const std::string& _content); 25 | void get_vod_url(const std::string& _content, int iIndex); 26 | private: 27 | std::string basexml_root_key_; 28 | std::string basexml_containurl_key_; 29 | std::string basejson_root_key_; 30 | std::string basejson_contain_key_; 31 | std::string basejson_url_key_; 32 | }; 33 | }; 34 | 35 | #endif //_resolve_letv_urls_ -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_qiyi_urls.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _resolve_qiyi_urls_ 2 | #define _resolve_qiyi_urls_ 3 | 4 | #include "urlcrack/crack_urls_base.hpp" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | namespace urlcrack 12 | { 13 | class qiyi_crack 14 | : public basic_crack 15 | { 16 | typedef qiyi_crack this_type; 17 | SHARED_ACCESS_DECLARE; 18 | public: 19 | static shared_ptr create(const std::string& strUrl, io_service& ios) 20 | { 21 | return shared_ptr(new this_type(strUrl, ios), 22 | shared_access_destroy()); 23 | } 24 | virtual void get_crack_urls(); 25 | protected: 26 | void get_base_xml_url(const std::string& _content); 27 | void get_base_urls(const std::string& _url); 28 | void get_time_rand_num(const std::vector& _urls); 29 | void modify_urls(const std::vector& _urls); 30 | void get_vod_urls(const std::vector& _urls); 31 | void process_base_url(const std::string& _content); 32 | void process_time_rand_num(const std::string& rand_num, std::vector _urls); 33 | void get_vod_url(const std::string& _content, int _index); 34 | qiyi_crack(const std::string& strUrl, io_service& ios); 35 | ~qiyi_crack(){}; 36 | private: 37 | std::string basexml_rootkey_; 38 | std::string basexml_vodkey_; 39 | std::string basexml_urlfilekey_; 40 | std::string basexml_filekey_; 41 | }; 42 | } 43 | #endif// _resolve_qiyi_urls_ -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_qq_urls.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _resolve_qq_urls_ 2 | #define _resolve_qq_urls_ 3 | 4 | #include "urlcrack/crack_urls_base.hpp" 5 | 6 | namespace urlcrack{ 7 | class qq_crack:public basic_crack 8 | { 9 | typedef qq_crack this_type; 10 | SHARED_ACCESS_DECLARE; 11 | public: 12 | static shared_ptr create(const std::string& _url, io_service& _ios) 13 | { 14 | return shared_ptr(new qq_crack(_url, _ios), 15 | shared_access_destroy()); 16 | } 17 | virtual void get_crack_urls(); 18 | protected: 19 | qq_crack(const std::string& _url, io_service& _ios):basic_crack(_url, _ios){}; 20 | ~qq_crack(){}; 21 | void get_mid_urls(const std::string& _content); 22 | void get_vod_url(const std::string& _content, int _index); 23 | }; 24 | } 25 | #endif //_resolve_qq_urls_ -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_sohu_urls.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/urlcrack/crack_sohu_urls.cpp -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_sohu_urls.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _resolve_sohu_urls_ 2 | #define _resolve_sohu_urls_ 3 | 4 | #include "urlcrack/crack_urls_base.hpp" 5 | 6 | namespace urlcrack 7 | { 8 | class sohu_crack:public basic_crack 9 | { 10 | typedef sohu_crack this_type; 11 | SHARED_ACCESS_DECLARE; 12 | public: 13 | static shared_ptr create(const std::string& _url, io_service& _ios) 14 | { 15 | return shared_ptr(new sohu_crack(_url, _ios), 16 | shared_access_destroy()); 17 | } 18 | virtual void get_crack_urls(); 19 | protected: 20 | sohu_crack(const std::string& _url, io_service& _ios); 21 | ~sohu_crack(){} 22 | private: 23 | void get_content_url(const std::string& _content); 24 | void process_content(std::string& _content); 25 | void get_vod_mid_urls(const std::string& _content); 26 | void get_vod_url(const std::string& _content, int _index); 27 | private: 28 | std::string basejson_allot_key_; 29 | std::string basejson_prot_key_; 30 | std::string basejson_data_key_; 31 | std::string basejson_su_key_; 32 | std::string basejson_clipurl_key_; 33 | std::string basejson_st_key_; 34 | std::string save_parameter_; 35 | std::vector save_su_urls; 36 | 37 | }; 38 | } 39 | #endif //_resolve_sohu_urls_ -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_urls_adapter.cpp: -------------------------------------------------------------------------------- 1 | #include "urlcrack/crack_urls_adapter.hpp" 2 | #include "urlcrack/crack_qiyi_urls.hpp" 3 | #include "urlcrack/crack_letv_urls.hpp" 4 | #include "urlcrack/crack_sohu_urls.hpp" 5 | #include "urlcrack/crack_qq_urls.hpp" 6 | #include "urlcrack/crack_youku_urls.hpp" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace urlcrack{ 16 | 17 | crack_adapter::crack_adapter(const std::string& _url, io_service& _ios) 18 | : basic_engine_object(_ios) 19 | { 20 | error_code ec; 21 | std::string strhost = p2engine::uri(_url, ec).host(); 22 | boost::regex urlreg("^[a-zA-Z]*\\.{0, 1}(.+)"); 23 | boost::smatch what; 24 | if (!boost::regex_match(strhost, what, urlreg)) 25 | { 26 | return; 27 | } 28 | strhost = std::string(what[1]); 29 | if (boost::icontains(strhost, "qiyi.com")) 30 | { 31 | base_resolve_ = qiyi_crack::create(_url, _ios); 32 | } 33 | else if (boost::icontains(strhost.c_str(), "letv.com")) 34 | { 35 | base_resolve_ = letv_crack::create(_url, _ios); 36 | } 37 | else if (boost::icontains(strhost.c_str(), "sohu.com")) 38 | { 39 | base_resolve_ = sohu_crack::create(_url, _ios); 40 | } 41 | else if (boost::icontains(strhost.c_str(), "qq.com")) 42 | { 43 | base_resolve_ = qq_crack::create(_url, _ios); 44 | } 45 | else if (boost::icontains(strhost.c_str(), "youku.com")) 46 | { 47 | base_resolve_ = youku_crack::create(_url, _ios); 48 | } 49 | } 50 | 51 | crack_adapter::call_back_signal& crack_adapter::get_crack_urls() 52 | { 53 | BOOST_ASSERT(base_resolve_); 54 | 55 | if (base_resolve_) 56 | { 57 | get_io_service().post( 58 | boost::bind(&basic_crack::get_crack_urls, base_resolve_) 59 | ); 60 | 61 | return base_resolve_->resolved_signal(); 62 | } 63 | dummy_signal_.clear(); 64 | return dummy_signal_; 65 | } 66 | 67 | }//end namespace urlcrack 68 | 69 | -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_urls_adapter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _resolve_urls_adapter_ 2 | #define _resolve_urls_adapter_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #include "urlcrack/crack_urls_base.hpp" 13 | 14 | namespace urlcrack 15 | { 16 | class crack_adapter 17 | : public basic_engine_object 18 | { 19 | typedef crack_adapter this_type; 20 | SHARED_ACCESS_DECLARE; 21 | 22 | public: 23 | typedef urlcrack::basic_crack basic_crack; 24 | typedef basic_crack::call_back_signal call_back_signal; 25 | 26 | static shared_ptr create(const std::string& _url, io_service& _ios) 27 | { 28 | return shared_ptr(new this_type(_url, _ios), 29 | shared_access_destroy()); 30 | } 31 | call_back_signal& get_crack_urls(); 32 | 33 | protected: 34 | template 35 | void dispatch_handler(Handler handler, const std::vector& _url)const 36 | { 37 | handler(_url); 38 | } 39 | 40 | crack_adapter(const std::string& strUrl, io_service& ios); 41 | ~crack_adapter(){}; 42 | private: 43 | basic_crack::shared_ptr base_resolve_; 44 | call_back_signal dummy_signal_; 45 | }; 46 | } 47 | #endif //_resolve_urls_adapter_ -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_urls_base.cpp: -------------------------------------------------------------------------------- 1 | #include "urlcrack/crack_urls_base.hpp" 2 | #include 3 | namespace urlcrack{ 4 | 5 | basic_crack::basic_crack(const std::string& _url, io_service& ios) 6 | : basic_engine_object(ios) 7 | , url_(_url) 8 | , result_url_count_(0) 9 | { 10 | watch_timer_ = rough_timer::create(ios); 11 | watch_timer_->set_obj_desc("urlcrack::basic_crack::watch_timer_"); 12 | watch_timer_->register_time_handler(boost::bind(&this_type::on_timer, this)); 13 | watch_timer_->async_keep_waiting(seconds(5), seconds(15)); 14 | }; 15 | 16 | basic_crack::~basic_crack() 17 | { 18 | if(watch_timer_) 19 | { 20 | watch_timer_->cancel(); 21 | watch_timer_->unregister_time_handler(); 22 | } 23 | 24 | }; 25 | 26 | void basic_crack::url_crack_sucess() 27 | { 28 | std::vector result_urls; 29 | std::map::const_iterator itr = mapresult_vod_urls_.begin(); 30 | while(itr!=mapresult_vod_urls_.end()) 31 | { 32 | result_urls.push_back(itr->second); 33 | ++itr; 34 | } 35 | finish_signal_(result_urls); 36 | } 37 | 38 | void basic_crack::on_timer() 39 | { 40 | download_keeper_.clear_timeout(); 41 | } 42 | } -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_urls_base.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/urlcrack/crack_urls_base.hpp -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_youku_urls.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/urlcrack/crack_youku_urls.cpp -------------------------------------------------------------------------------- /src/lib/urlcrack/crack_youku_urls.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _resolve_youku_urls_ 2 | #define _resolve_youku_urls_ 3 | #include "urlcrack/crack_urls_base.hpp" 4 | namespace urlcrack{ 5 | class youku_crack:public basic_crack 6 | { 7 | typedef youku_crack this_type; 8 | SHARED_ACCESS_DECLARE; 9 | public: 10 | static shared_ptr create(const std::string& _url, io_service& _ios) 11 | { 12 | return shared_ptr(new youku_crack(_url, _ios) 13 | , shared_access_destroy()); 14 | } 15 | virtual void get_crack_urls(); 16 | protected: 17 | youku_crack(const std::string& _url, io_service& _ios):basic_crack(_url, _ios){}; 18 | ~youku_crack(){}; 19 | std::string get_file_idmix_string(const std::string& _seed); 20 | std::string get_file_id(const std::string& _file_id, const std::string& _seed); 21 | std::string generate_key(const std::string& _key1, const std::string& _key2); 22 | std::string generate_sid(); 23 | void get_vod_urls(const std::string& _content); 24 | }; 25 | } 26 | #endif //_resolve_youku_urls_ -------------------------------------------------------------------------------- /src/lib/urlcrack/urlcrack.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/lib/urlcrack/urlcrack.vcproj -------------------------------------------------------------------------------- /src/lib/urlcrack/urlcrack.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /src/test/asfile_test/asfile_test.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/asfile_test/asfile_test.vcproj -------------------------------------------------------------------------------- /src/test/client_test/client_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/client_test/client_test.cpp -------------------------------------------------------------------------------- /src/test/client_test/client_test.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/client_test/client_test.vcproj -------------------------------------------------------------------------------- /src/test/dht_test/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : dht_test Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this dht_test application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your dht_test application. 9 | 10 | 11 | dht_test.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | dht_test.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | dht_test.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named dht_test.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /src/test/dht_test/channel_list_send.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/dht_test/channel_list_send.cpp -------------------------------------------------------------------------------- /src/test/dht_test/dht_test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/test/dht_test/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // dht_test.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/test/dht_test/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /src/test/dht_test/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /src/test/dht_test_1/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : command_manager Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this command_manager application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your command_manager application. 9 | 10 | 11 | command_manager.vcxproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | command_manager.vcxproj.filters 18 | This is the filters file for VC++ projects generated using an Application Wizard. 19 | It contains information about the association between the files in your project 20 | and the filters. This association is used in the IDE to show grouping of files with 21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 22 | "Source Files" filter). 23 | 24 | command_manager.cpp 25 | This is the main application source file. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other standard files: 29 | 30 | StdAfx.h, StdAfx.cpp 31 | These files are used to build a precompiled header (PCH) file 32 | named command_manager.pch and a precompiled types file named StdAfx.obj. 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | Other notes: 36 | 37 | AppWizard uses "TODO:" comments to indicate parts of the source code you 38 | should add to or customize. 39 | 40 | ///////////////////////////////////////////////////////////////////////////// 41 | -------------------------------------------------------------------------------- /src/test/dht_test_1/channel_list_get.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/dht_test_1/channel_list_get.cpp -------------------------------------------------------------------------------- /src/test/dht_test_1/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // command_manager.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/test/dht_test_1/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /src/test/dht_test_1/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /src/test/peer_test/peer_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/peer_test/peer_test.cpp -------------------------------------------------------------------------------- /src/test/server_test/server_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/server_test/server_test.cpp -------------------------------------------------------------------------------- /src/test/server_test/server_test.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/server_test/server_test.vcproj -------------------------------------------------------------------------------- /src/test/test/RemoveCommentary.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/test/RemoveCommentary.exe -------------------------------------------------------------------------------- /src/test/test/include/utf8.h: -------------------------------------------------------------------------------- 1 | // Copyright 2006 Nemanja Trifunovic 2 | 3 | /* 4 | Permission is hereby granted, free of charge, to any person or organization 5 | obtaining a copy of the software and accompanying documentation covered by 6 | this license (the "Software") to use, reproduce, display, distribute, 7 | execute, and transmit the Software, and to prepare derivative works of the 8 | Software, and to permit third-parties to whom the Software is furnished to 9 | do so, all subject to the following: 10 | 11 | The copyright notices in the Software and this entire statement, including 12 | the above license grant, this restriction and the following disclaimer, 13 | must be included in all copies of the Software, in whole or in part, and 14 | all derivative works of the Software, unless such copies or derivative 15 | works are solely in the form of machine-executable object code generated by 16 | a source language processor. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 21 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 22 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 23 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | 28 | #ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731 29 | #define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731 30 | 31 | #include "utf8/checked.h" 32 | #include "utf8/unchecked.h" 33 | 34 | #endif // header guard 35 | -------------------------------------------------------------------------------- /src/test/test/test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/test/test.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | 6 | -------------------------------------------------------------------------------- /src/test/test_playe/test_player.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/test_playe/test_player.vcproj -------------------------------------------------------------------------------- /src/test/tracker_test/tracker_test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/tracker_test/tracker_test.cpp -------------------------------------------------------------------------------- /src/test/tracker_test/tracker_test.vcproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/guangzhuwu/p2streaming/b0451d11e33f1f150f0eaad3b1abee108d018473/src/test/tracker_test/tracker_test.vcproj -------------------------------------------------------------------------------- /src/test/unit_test.h: -------------------------------------------------------------------------------- 1 | // 2 | // unit_test.hpp 3 | // ~~~~~~~~~~~~~ 4 | // 5 | // Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) 6 | // 7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying 8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 | // 10 | 11 | #ifndef UNIT_TEST_HPP 12 | #define UNIT_TEST_HPP 13 | 14 | #include 15 | 16 | #if defined(__sun) 17 | # include // Needed for lrand48. 18 | #endif // defined(__sun) 19 | 20 | #if defined(__BORLANDC__) 21 | 22 | // Prevent use of intrinsic for strcmp. 23 | # include 24 | # undef strcmp 25 | 26 | // Suppress error about condition always being true. 27 | # pragma option -w-ccc 28 | 29 | #endif // defined(__BORLANDC__) 30 | 31 | #if defined(BOOST_MSVC) 32 | # pragma warning (push) 33 | # pragma warning (disable:4244) 34 | # pragma warning (disable:4702) 35 | #endif // defined(BOOST_MSVC) 36 | 37 | #include 38 | using boost::unit_test::test_suite; 39 | 40 | #if defined(BOOST_MSVC) 41 | # pragma warning (pop) 42 | #endif // defined(BOOST_MSVC) 43 | 44 | inline void null_test() 45 | { 46 | } 47 | 48 | #endif // UNIT_TEST_HPP 49 | --------------------------------------------------------------------------------