コード例 #1
0
void CSensorBackendSym::GetPropertiesL()
    {
    //description
    GetDescription();
    
    //data rate
    GetDataRate();
    
    //accuracy and measurement ranges
    GetMeasurementrangeAndAccuracy();
    }
コード例 #2
0
    bool LiveDownloadDriver::ShouldUseCdnToAccelerate()
    {
        if (!is_history_upload_good_)
        {
            return false;
        }

        if (live_streams_[data_rate_manager_.GetCurrentDataRatePos()]->GetTimesOfUseCdnBecauseOfLargeUpload() != 0 &&
            tick_counter_since_last_advance_using_cdn_.elapsed() < BootStrapGeneralConfig::Inst()->GetMinIntervalOfCdnAccelerationDelim(is_saving_mode_) * 1000)
        {
            return false;
        }

        if (GetP2PControlTarget() && GetP2PControlTarget()->GetPooledPeersCount() >= BootStrapGeneralConfig::Inst()->GetDesirableLiveIpPoolSize() &&
            statistic::UploadStatisticModule::Inst()->GetUploadCount() > BootStrapGeneralConfig::Inst()->GetUploadConnectionCountDelim(is_saving_mode_) &&
            statistic::UploadStatisticModule::Inst()->GetUploadSpeed() > GetDataRate() * BootStrapGeneralConfig::Inst()->GetNotStrictRatioDelimOfUploadToDatarate(is_saving_mode_) / 100)
        {
            tick_counter_since_last_advance_using_cdn_.reset();
            return true;
        }

        return false;
    }
コード例 #3
0
 bool LiveDownloadDriver::IsUploadSpeedSmallEnough()
 {
     return statistic::StatisticModule::Inst()->GetMinuteUploadDataSpeed() < GetDataRate() * small_ratio_delim_of_upload_speed_to_datarate_ / 100;
 }
コード例 #4
0
    void LiveDownloadDriver::UpdateStatisticInfo()
    {
        // rid
        live_download_driver_statistic_info_.ResourceID = GetInstance()->GetRID();

        // speed info
        live_download_driver_statistic_info_.LiveHttpSpeedInfo = GetHTTPControlTarget()->GetSpeedInfo();
        live_download_driver_statistic_info_.LiveP2PSpeedInfo = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetSpeedInfo() : statistic::SPEED_INFO();
        live_download_driver_statistic_info_.LiveP2PSubPieceSpeedInfo = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetSubPieceSpeedInfo() : statistic::SPEED_INFO();

        // http status code
        live_download_driver_statistic_info_.LastHttpStatusCode = GetHTTPControlTarget()->GetHttpStatusCode();

        // switch state
        live_download_driver_statistic_info_.http_state = switch_state_http_;
        live_download_driver_statistic_info_.p2p_state = switch_state_p2p_;

        // peer count
        live_download_driver_statistic_info_.PeerCount = GetP2PControlTarget() ? GetP2PControlTarget()->GetConnectedPeersCount() : 0;

        // ip pool
        live_download_driver_statistic_info_.IpPoolPeerCount = GetP2PControlTarget() ? GetP2PControlTarget()->GetPooledPeersCount() : 0;

        // total unused subpiece count
        live_download_driver_statistic_info_.TotalUnusedSubPieceCount = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetTotalUnusedSubPieceCount() : 0;

        // total all request subpiece count
        live_download_driver_statistic_info_.TotalAllRequestSubPieceCount = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetTotalAllRequestSubPieceCount() : 0;

        // total recieved subpiece count
        live_download_driver_statistic_info_.TotalRecievedSubPieceCount = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetTotalRecievedSubPieceCount() : 0;

        // total request subpiece count
        live_download_driver_statistic_info_.TotalRequestSubPieceCount = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetTotalRequestSubPieceCount() : 0;

        // total p2p data bytes
        live_download_driver_statistic_info_.TotalP2PDataBytes = GetP2PControlTarget() ? GetP2PControlTarget()->GetTotalP2PDataBytes() : 0;

        // cache size
        live_download_driver_statistic_info_.CacheSize = GetInstance()->GetCacheSize();

        // first cache block id
        live_download_driver_statistic_info_.CacheFirstBlockId = GetInstance()->GetCacheFirstBlockId();

        // last cache block id
        live_download_driver_statistic_info_.CacheLastBlockId = GetInstance()->GetCacheLastBlockId();

        // playing position
        live_download_driver_statistic_info_.PlayingPosition = playing_position_.GetBlockId();

        // rest play time
        live_download_driver_statistic_info_.RestPlayTime = GetRestPlayableTime();

        // data rate
        live_download_driver_statistic_info_.DataRate = GetDataRate();

        // play position block full or not
        live_download_driver_statistic_info_.IsPlayingPositionBlockFull = IsPlayingPositionBlockFull();

        // peer connection info
        if (GetP2PControlTarget())
        {
            const std::map<boost::asio::ip::udp::endpoint, boost::shared_ptr<p2sp::LivePeerConnection> > & peer_connections
                = GetP2PControlTarget()->GetPeers();

            int i = 0;
            for (std::map<boost::asio::ip::udp::endpoint, boost::shared_ptr<p2sp::LivePeerConnection> >::const_iterator iter
                = peer_connections.begin(); iter != peer_connections.end(); ++iter, ++i)
            {
                live_download_driver_statistic_info_.P2PConnections[i] = iter->second->GetPeerConnectionInfo();
            }
        }

        // left capacity
#ifdef USE_MEMORY_POOL
        live_download_driver_statistic_info_.LeftCapacity = protocol::LiveSubPieceContent::get_left_capacity();
#endif

        // live point block id
        live_download_driver_statistic_info_.LivePointBlockId = GetInstance()->GetCurrentLivePoint().GetBlockId();

        // data rate level
        live_download_driver_statistic_info_.DataRateLevel = data_rate_manager_.GetCurrentDataRatePos();

        // jump times
        live_download_driver_statistic_info_.JumpTimes = jump_times_;

        // checksum failed
        live_download_driver_statistic_info_.NumOfChecksumFailedPieces =
            checksum_failed_times_ + GetInstance()->GetChecksumFailedTimes();

        // udp server download bytes
        live_download_driver_statistic_info_.TotalUdpServerDataBytes = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetTotalUdpServerDataBytes() : 0;

        // pms status
        live_download_driver_statistic_info_.PmsStatus = GetHTTPControlTarget()->GetPmsStatus() ? 0 : 1;

        // udpserver speed
        live_download_driver_statistic_info_.UdpServerSpeedInfo = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetUdpServerSpeedInfo() : statistic::SPEED_INFO();

        // pause
        live_download_driver_statistic_info_.IsPaused = rest_time_tracker_.IsPaused() ? 1 : 0;

        // replay
        live_download_driver_statistic_info_.IsReplay = replay_ ? 1 : 0;

        // missing subpiece count of first block
        live_download_driver_statistic_info_.MissingSubPieceCountOfFirstBlock = GetInstance()->GetMissingSubPieceCount(playing_position_.GetBlockId());

        // exist subpiece count of first block
        live_download_driver_statistic_info_.ExistSubPieceCountOfFirstBlock = GetInstance()->GetExistSubPieceCount(playing_position_.GetBlockId());

        // peer 一秒的速度
        live_download_driver_statistic_info_.P2PPeerSpeedInSecond = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetSubPieceSpeedInfoEx().SecondDownloadSpeed : 0;

        // udpserver 一秒的速度
        live_download_driver_statistic_info_.P2PUdpServerSpeedInSecond = GetP2PControlTarget() ?
            GetP2PControlTarget()->GetUdpServerSpeedInfoEx().SecondDownloadSpeed : 0;
    }
コード例 #5
0
    void LiveDownloadDriver::OnTimerElapsed(framework::timer::Timer * pointer)
    {
        if (pointer == &timer_)
        {
            if (playing_position_.GetSubPieceIndex() == 0)
            {
                JumpOrSwitchIfNeeded();
            }

#ifndef STATISTIC_OFF
            UpdateStatisticInfo();
            statistic_->UpdateShareMemory();
#endif
            if (http_download_max_speed_ < GetHTTPControlTarget()->GetSpeedInfo().NowDownloadSpeed)
            {
                http_download_max_speed_ = GetHTTPControlTarget()->GetSpeedInfo().NowDownloadSpeed;
            }

            if (GetP2PControlTarget())
            {
                if (p2p_download_max_speed_ < GetP2PControlTarget()->GetSpeedInfo().NowDownloadSpeed)
                {
                    p2p_download_max_speed_ = GetP2PControlTarget()->GetSpeedInfo().NowDownloadSpeed;
                }

                if (udp_server_max_speed_ < GetP2PControlTarget()->GetUdpServerSpeedInfo().NowDownloadSpeed)
                {
                    udp_server_max_speed_ = GetP2PControlTarget()->GetUdpServerSpeedInfo().NowDownloadSpeed;
                }
            }

            ++elapsed_seconds_since_started_;
            if (bufferring_monitor_)
            {
                if (elapsed_seconds_since_started_ > 10 &&
                    GetRestPlayableTime() <= 1)
                {
                    boost::uint32_t data_rate = GetDataRate();
                    if (data_rate > 0)
                    {
                        storage::LivePosition live_position = GetPlayingPosition();
                        boost::uint32_t bufferring_position_in_seconds = live_position.GetBlockId()*GetInstance()->GetLiveInterval() + 
                            live_position.GetSubPieceIndex()*storage::HeaderSubPiece::Constants::SubPieceSizeInBytes/data_rate;
                        bufferring_monitor_->BufferringOccurs(bufferring_position_in_seconds);
                    }
                }
            }

            if (max_upload_speed_during_this_connection_ < statistic::UploadStatisticModule::Inst()->GetUploadSpeed())
            {
                max_upload_speed_during_this_connection_ = statistic::UploadStatisticModule::Inst()->GetUploadSpeed();
            }

            total_upload_connection_count_ += statistic::UploadStatisticModule::Inst()->GetUploadCount();

            if (statistic::UploadStatisticModule::Inst()->GetUploadCount() != 0)
            {
                ++time_of_nonblank_upload_connections_;
            }

            rest_playable_times_.push_back(GetRestPlayableTime());

            if (tick_count_since_last_recv_subpiece_.elapsed() > 180 * 1000 && !is_notify_restart_
                && ((GetHTTPControlTarget() && !GetHTTPControlTarget()->IsPausing()) ||
                (GetP2PControlTarget() && !GetP2PControlTarget()->IsPausing())))
            {
#ifdef PEER_PC_CLIENT
                WindowsMessage::Inst().PostWindowsMessage(UM_LIVE_RESTART, NULL, NULL);
                is_notify_restart_ = true;

                max_push_data_interval_ = tick_count_since_last_recv_subpiece_.elapsed();
#endif
            }

            if (udpserver_count_ != UdpServerFromBSPool::Inst()->GetUdpServerCount())
            {
                udpserver_count_ = UdpServerFromBSPool::Inst()->GetUdpServerCount();
                AddLiveUdpServerFromBS();
            }
        }
    }