bool CAttackDetector::Hit (int iTick) // Hit // // Register a hit. Returns TRUE if there have been enough hits that we should // count the attack as deliberate. { if (IsBlacklisted()) return true; // If we were hit recently, then ignore the hit because it is probably // from a multi-shot weapon (or a fragmentation weapon) if (iTick - m_iLastHit > MULTI_HIT_WINDOW) { m_iCounter++; m_iLastHit = iTick; if (m_iCounter > HIT_LIMIT) { m_iCounter = -1; return true; } } return false; }
bool DeleteBlacklisted(uint32 ownerId, uint32 targetId) { if (!IsBlacklisted(ownerId, targetId)) return false; const int8* sql = "DELETE FROM char_blacklist WHERE charid_owner = %u AND charid_target = %u;"; return (Sql_Query(SqlHandle, sql, ownerId, targetId) != SQL_ERROR && Sql_AffectedRows(SqlHandle) == 1); }
bool AddBlacklisted(uint32 ownerId, uint32 targetId) { if (IsBlacklisted(ownerId, targetId)) return false; const int8* sql = "INSERT INTO char_blacklist (charid_owner, charid_target) VALUES (%u, %u);"; return (Sql_Query(SqlHandle, sql, ownerId, targetId) != SQL_ERROR && Sql_AffectedRows(SqlHandle) == 1); }
bool CDVDVideoCodecAndroidMediaCodec::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) { // check for 4.1 Jellybean and above. if (CAndroidFeatures::GetVersion() < 16) return false; // mediacodec crashes with null size. Trap this... if (!hints.width || !hints.height) { CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open - %s\n", "null size, cannot handle"); return false; } m_drop = false; m_hints = hints; switch(m_hints.codec) { case AV_CODEC_ID_MPEG2VIDEO: m_mime = "video/mpeg2"; m_formatname = "amc-mpeg2"; break; case AV_CODEC_ID_MPEG4: m_mime = "video/mp4v-es"; m_formatname = "amc-mpeg4"; break; case AV_CODEC_ID_H263: m_mime = "video/3gpp"; m_formatname = "amc-h263"; break; case AV_CODEC_ID_VP3: case AV_CODEC_ID_VP6: case AV_CODEC_ID_VP6F: case AV_CODEC_ID_VP8: //m_mime = "video/x-vp6"; //m_mime = "video/x-vp7"; m_mime = "video/x-vnd.on2.vp8"; m_formatname = "amc-vpX"; break; case AV_CODEC_ID_AVS: case AV_CODEC_ID_CAVS: case AV_CODEC_ID_H264: m_mime = "video/avc"; m_formatname = "amc-h264"; // check for h264-avcC and convert to h264-annex-b if (m_hints.extradata && *(uint8_t*)m_hints.extradata == 1) { m_bitstream = new CBitstreamConverter; if (!m_bitstream->Open(m_hints.codec, (uint8_t*)m_hints.extradata, m_hints.extrasize, true)) { SAFE_DELETE(m_bitstream); return false; } } break; case AV_CODEC_ID_VC1: case AV_CODEC_ID_WMV3: m_mime = "video/wvc1"; //m_mime = "video/wmv9"; m_formatname = "amc-vc1"; break; default: CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec:: Unknown hints.codec(%d)", hints.codec); return false; break; } // CJNIMediaCodec::createDecoderByXXX doesn't handle errors nicely, // it crashes if the codec isn't found. This is fixed in latest AOSP, // but not in current 4.1 devices. So 1st search for a matching codec, then create it. m_colorFormat = -1; int num_codecs = CJNIMediaCodecList::getCodecCount(); for (int i = 0; i < num_codecs; i++) { CJNIMediaCodecInfo codec_info = CJNIMediaCodecList::getCodecInfoAt(i); if (codec_info.isEncoder()) continue; m_codecname = codec_info.getName(); if (IsBlacklisted(m_codecname)) continue; CJNIMediaCodecInfoCodecCapabilities codec_caps = codec_info.getCapabilitiesForType(m_mime); if (xbmc_jnienv()->ExceptionOccurred()) { // Unsupported type? xbmc_jnienv()->ExceptionClear(); continue; } std::vector<int> color_formats = codec_caps.colorFormats(); std::vector<std::string> types = codec_info.getSupportedTypes(); // return the 1st one we find, that one is typically 'the best' for (size_t j = 0; j < types.size(); ++j) { if (types[j] == m_mime) { m_codec = boost::shared_ptr<CJNIMediaCodec>(new CJNIMediaCodec(CJNIMediaCodec::createByCodecName(m_codecname))); // clear any jni exceptions, jni gets upset if we do not. if (xbmc_jnienv()->ExceptionOccurred()) { CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec::Open ExceptionOccurred"); xbmc_jnienv()->ExceptionClear(); m_codec.reset(); continue; } for (size_t k = 0; k < color_formats.size(); ++k) { CLog::Log(LOGDEBUG, "CDVDVideoCodecAndroidMediaCodec::Open " "m_codecname(%s), colorFormat(%d)", m_codecname.c_str(), color_formats[k]); if (IsSupportedColorFormat(color_formats[k])) m_colorFormat = color_formats[k]; // Save color format for initial output configuration } break; } } if (m_codec) break; } if (!m_codec) { CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec:: Failed to create Android MediaCodec"); SAFE_DELETE(m_bitstream); return false; } // blacklist of devices that cannot surface render. m_render_sw = CanSurfaceRenderBlackList(m_codecname) || g_advancedSettings.m_mediacodecForceSoftwareRendring; if (m_render_sw) { if (m_colorFormat == -1) { CLog::Log(LOGERROR, "CDVDVideoCodecAndroidMediaCodec:: No supported color format"); m_codec.reset(); SAFE_DELETE(m_bitstream); return false; } } // setup a YUV420P DVDVideoPicture buffer. // first make sure all properties are reset. memset(&m_videobuffer, 0x00, sizeof(DVDVideoPicture)); m_videobuffer.dts = DVD_NOPTS_VALUE; m_videobuffer.pts = DVD_NOPTS_VALUE; m_videobuffer.color_range = 0; m_videobuffer.color_matrix = 4; m_videobuffer.iFlags = DVP_FLAG_ALLOCATED; m_videobuffer.iWidth = m_hints.width; m_videobuffer.iHeight = m_hints.height; // these will get reset to crop values later m_videobuffer.iDisplayWidth = m_hints.width; m_videobuffer.iDisplayHeight = m_hints.height; if (!ConfigureMediaCodec()) { m_codec.reset(); SAFE_DELETE(m_bitstream); return false; } CLog::Log(LOGINFO, "CDVDVideoCodecAndroidMediaCodec:: " "Open Android MediaCodec %s", m_codecname.c_str()); m_opened = true; return m_opened; }