static jboolean android_net_wifi_setHotlist( JNIEnv *env, jclass cls, jint iface, jint id, jobject ap) { wifi_interface_handle handle = getIfaceHandle(env, cls, iface); ALOGD("setting hotlist on interface[%d] = %p", iface, handle); wifi_bssid_hotlist_params params; memset(¶ms, 0, sizeof(params)); jobjectArray array = (jobjectArray) getObjectField(env, ap, "bssidInfos", "[Landroid/net/wifi/WifiScanner$BssidInfo;"); params.num_ap = env->GetArrayLength(array); if (params.num_ap == 0) { ALOGE("Error in accesing array"); return false; } for (int i = 0; i < params.num_ap; i++) { jobject objAp = env->GetObjectArrayElement(array, i); jstring macAddrString = (jstring) getObjectField( env, objAp, "bssid", "Ljava/lang/String;"); if (macAddrString == NULL) { ALOGE("Error getting bssid field"); return false; } ScopedUtfChars bssid(env, macAddrString); if (bssid.c_str() == NULL) { ALOGE("Error getting bssid"); return false; } parseMacAddress(bssid.c_str(), params.ap[i].bssid); mac_addr addr; memcpy(addr, params.ap[i].bssid, sizeof(mac_addr)); char bssidOut[32]; sprintf(bssidOut, "%0x:%0x:%0x:%0x:%0x:%0x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); ALOGD("Added bssid %s", bssidOut); params.ap[i].low = getIntField(env, objAp, "low"); params.ap[i].high = getIntField(env, objAp, "high"); } wifi_hotlist_ap_found_handler handler; memset(&handler, 0, sizeof(handler)); handler.on_hotlist_ap_found = &onHotlistApFound; return wifi_set_bssid_hotlist(id, handle, params, handler) == WIFI_SUCCESS; }
void Java_com_mathieu_alloclient_Pipe_closeInput(JNIEnv *env, jobject obj) { FileDescriptor input; if(!getObjectField(env, obj, "input", "Ljava/io/FileDescriptor;", &input)) return; if(!closeFileDescriptor(env, input)) return; }
/* return has eoo() true if no match supports "." notation to reach into embedded objects */ BSONElement BSONObj::getFieldDotted(const char *name) const { BSONElement e = getField( name ); if ( e.eoo() ) { const char *p = strchr(name, '.'); if ( p ) { string left(name, p-name); BSONObj sub = getObjectField(left.c_str()); return sub.isEmpty() ? nullElement : sub.getFieldDotted(p+1); } } return e; }
void NotifyPluginConfiguration::saveState(QSettings* settings) const { settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath())); settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage()); settings->setValue(QLatin1String("ObjectField"), getObjectField()); settings->setValue(QLatin1String("DataObject"), getDataObject()); settings->setValue(QLatin1String("Value"), getValue()); settings->setValue(QLatin1String("ValueSpinBox"), getSpinBoxValue()); settings->setValue(QLatin1String("Sound1"), getSound1()); settings->setValue(QLatin1String("Sound2"), getSound2()); settings->setValue(QLatin1String("Sound3"), getSound3()); settings->setValue(QLatin1String("SayOrder"), getSayOrder()); settings->setValue(QLatin1String("Repeat"), getRepeatFlag()); settings->setValue(QLatin1String("ExpireTimeout"), getExpireTimeout()); }
StatusWith<std::vector<BSONObj>> selectChunkSplitPoints(OperationContext* txn, const ShardId& shardId, const NamespaceString& nss, const ShardKeyPattern& shardKeyPattern, const BSONObj& minKey, const BSONObj& maxKey, long long chunkSizeBytes, int maxPoints, int maxObjs) { BSONObjBuilder cmd; cmd.append("splitVector", nss.ns()); cmd.append("keyPattern", shardKeyPattern.toBSON()); cmd.append(kMinKey, minKey); cmd.append(kMaxKey, maxKey); cmd.append("maxChunkSizeBytes", chunkSizeBytes); cmd.append("maxSplitPoints", maxPoints); cmd.append("maxChunkObjects", maxObjs); auto shard = Grid::get(txn)->shardRegistry()->getShard(txn, shardId); if (!shard) { return Status(ErrorCodes::ShardNotFound, str::stream() << "shard " << shardId << " not found"); } auto cmdStatus = shard->runCommand(txn, ReadPreferenceSetting{ReadPreference::PrimaryPreferred}, "admin", cmd.obj(), Shard::RetryPolicy::kIdempotent); if (!cmdStatus.isOK()) { return std::move(cmdStatus.getStatus()); } if (!cmdStatus.getValue().commandStatus.isOK()) { return std::move(cmdStatus.getValue().commandStatus); } const auto response = std::move(cmdStatus.getValue().response); std::vector<BSONObj> splitPoints; BSONObjIterator it(response.getObjectField("splitKeys")); while (it.more()) { splitPoints.push_back(it.next().Obj().getOwned()); } return std::move(splitPoints); }
void NotificationItem::saveState(QSettings* settings) const { settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath())); settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage()); settings->setValue(QLatin1String("ObjectField"), getObjectField()); settings->setValue(QLatin1String("DataObject"), getDataObject()); settings->setValue(QLatin1String("RangeLimit"), getCondition()); settings->setValue(QLatin1String("Value1"), singleValue()); settings->setValue(QLatin1String("Value2"), valueRange2()); settings->setValue(QLatin1String("Sound1"), getSound1()); settings->setValue(QLatin1String("Sound2"), getSound2()); settings->setValue(QLatin1String("Sound3"), getSound3()); settings->setValue(QLatin1String("SayOrder"), getSayOrder()); settings->setValue(QLatin1String("Repeat"), retryValue()); settings->setValue(QLatin1String("ExpireTimeout"), lifetime()); settings->setValue(QLatin1String("Mute"), mute()); }
StatusWith<std::vector<BSONObj>> selectChunkSplitPoints(OperationContext* txn, const ShardId& shardId, const NamespaceString& nss, const ShardKeyPattern& shardKeyPattern, const ChunkRange& chunkRange, long long chunkSizeBytes, boost::optional<int> maxObjs) { BSONObjBuilder cmd; cmd.append("splitVector", nss.ns()); cmd.append("keyPattern", shardKeyPattern.toBSON()); chunkRange.append(&cmd); cmd.append("maxChunkSizeBytes", chunkSizeBytes); if (maxObjs) { cmd.append("maxChunkObjects", *maxObjs); } auto shardStatus = Grid::get(txn)->shardRegistry()->getShard(txn, shardId); if (!shardStatus.isOK()) { return shardStatus.getStatus(); } auto cmdStatus = shardStatus.getValue()->runCommandWithFixedRetryAttempts( txn, ReadPreferenceSetting{ReadPreference::PrimaryPreferred}, "admin", cmd.obj(), Shard::RetryPolicy::kIdempotent); if (!cmdStatus.isOK()) { return std::move(cmdStatus.getStatus()); } if (!cmdStatus.getValue().commandStatus.isOK()) { return std::move(cmdStatus.getValue().commandStatus); } const auto response = std::move(cmdStatus.getValue().response); std::vector<BSONObj> splitPoints; BSONObjIterator it(response.getObjectField("splitKeys")); while (it.more()) { splitPoints.push_back(it.next().Obj().getOwned()); } return std::move(splitPoints); }
static bool parseMacAddress(JNIEnv *env, jobject obj, mac_addr addr) { jstring macAddrString = (jstring) getObjectField( env, obj, "bssid", "Ljava/lang/String;"); if (macAddrString == NULL) { ALOGE("Error getting bssid field"); return false; } ScopedUtfChars bssid(env, macAddrString); if (bssid.c_str() == NULL) { ALOGE("Error getting bssid"); return false; } parseMacAddress(bssid.c_str(), addr); return true; }
JNIEXPORT void JNICALL Java_org_alex73_android_common_JniWrapper_getPermissions (JNIEnv *env, jclass cl, jobject fi) { jobject path = getObjectField(env, fi, "path", "Ljava/lang/String;"); struct stat buf; const char *nativePath = (*env)->GetStringUTFChars(env, path, 0); int r=stat(nativePath, &buf); (*env)->ReleaseStringUTFChars(env, path, nativePath); if (r==0) { setLongField(env, fi, "perm", buf.st_mode); setLongField(env, fi, "owner", buf.st_uid); setLongField(env, fi, "group", buf.st_gid); } else { setLongField(env, fi, "perm", -1); setLongField(env, fi, "owner", -1); setLongField(env, fi, "group", -1); } }
StatusWith<BSONObj> selectMedianKey(OperationContext* txn, const ShardId& shardId, const NamespaceString& nss, const ShardKeyPattern& shardKeyPattern, const BSONObj& minKey, const BSONObj& maxKey) { BSONObjBuilder cmd; cmd.append("splitVector", nss.ns()); cmd.append("keyPattern", shardKeyPattern.toBSON()); cmd.append(kMinKey, minKey); cmd.append(kMaxKey, maxKey); cmd.appendBool("force", true); auto shard = Grid::get(txn)->shardRegistry()->getShard(txn, shardId); if (!shard) { return Status(ErrorCodes::ShardNotFound, str::stream() << "shard " << shardId << " not found"); } auto cmdStatus = shard->runCommand(txn, ReadPreferenceSetting{ReadPreference::PrimaryPreferred}, "admin", cmd.obj(), Shard::RetryPolicy::kIdempotent); if (!cmdStatus.isOK()) { return std::move(cmdStatus.getStatus()); } if (!cmdStatus.getValue().commandStatus.isOK()) { return std::move(cmdStatus.getValue().commandStatus); } const auto response = std::move(cmdStatus.getValue().response); BSONObjIterator it(response.getObjectField("splitKeys")); if (it.more()) { return it.next().Obj().getOwned(); } return BSONObj(); }
jobject getFieldValue(JNIEnv * env, jobject obj, jclass fieldClass, jfieldID fieldId) { char* signature; (*jvmti)->GetClassSignature(jvmti, fieldClass, &signature, 0 ); if (strcmp(signature, "Z") == 0) { return getBooleanField(env, obj, fieldId); } else if (strcmp(signature, "B") == 0) { return getByteField(env, obj, fieldId); } else if (strcmp(signature, "C") == 0) { return getCharField(env, obj, fieldId); } else if (strcmp(signature, "S") == 0) { return getShortField(env, obj, fieldId); } else if (strcmp(signature, "I") == 0) { return getIntField(env, obj, fieldId); } else if (strcmp(signature, "J") == 0) { return getLongField(env, obj, fieldId); } else if (strcmp(signature, "F") == 0) { return getFloatField(env, obj, fieldId); } else if (strcmp(signature, "D") == 0) { return getDoubleField(env, obj, fieldId); } else { return getObjectField(env, obj, fieldId); } }
static jboolean android_net_wifi_trackSignificantWifiChange( JNIEnv *env, jclass cls, jint iface, jint id, jobject settings) { wifi_interface_handle handle = getIfaceHandle(env, cls, iface); ALOGD("tracking significant wifi change on interface[%d] = %p", iface, handle); wifi_significant_change_params params; memset(¶ms, 0, sizeof(params)); params.rssi_sample_size = getIntField(env, settings, "rssiSampleSize"); params.lost_ap_sample_size = getIntField(env, settings, "lostApSampleSize"); params.min_breaching = getIntField(env, settings, "minApsBreachingThreshold"); const char *bssid_info_array_type = "[Landroid/net/wifi/WifiScanner$BssidInfo;"; jobjectArray bssids = (jobjectArray)getObjectField( env, settings, "bssidInfos", bssid_info_array_type); params.num_ap = env->GetArrayLength(bssids); if (params.num_ap == 0) { ALOGE("Error in accessing array"); return false; } ALOGD("Initialized common fields %d, %d, %d, %d", params.rssi_sample_size, params.lost_ap_sample_size, params.min_breaching, params.num_ap); for (int i = 0; i < params.num_ap; i++) { jobject objAp = env->GetObjectArrayElement(bssids, i); jstring macAddrString = (jstring) getObjectField( env, objAp, "bssid", "Ljava/lang/String;"); if (macAddrString == NULL) { ALOGE("Error getting bssid field"); return false; } ScopedUtfChars bssid(env, macAddrString); if (bssid.c_str() == NULL) { ALOGE("Error getting bssid"); return false; } mac_addr addr; parseMacAddress(bssid.c_str(), addr); memcpy(params.ap[i].bssid, addr, sizeof(mac_addr)); char bssidOut[32]; sprintf(bssidOut, "%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); params.ap[i].low = getIntField(env, objAp, "low"); params.ap[i].high = getIntField(env, objAp, "high"); ALOGD("Added bssid %s, [%04d, %04d]", bssidOut, params.ap[i].low, params.ap[i].high); } ALOGD("Added %d bssids", params.num_ap); wifi_significant_change_handler handler; memset(&handler, 0, sizeof(handler)); handler.on_significant_change = &onSignificantWifiChange; return wifi_set_significant_change_handler(id, handle, params, handler) == WIFI_SUCCESS; }
static jboolean android_net_wifi_startScan( JNIEnv *env, jclass cls, jint iface, jint id, jobject settings) { wifi_interface_handle handle = getIfaceHandle(env, cls, iface); ALOGD("starting scan on interface[%d] = %p", iface, handle); wifi_scan_cmd_params params; memset(¶ms, 0, sizeof(params)); params.base_period = getIntField(env, settings, "base_period_ms"); params.max_ap_per_scan = getIntField(env, settings, "max_ap_per_scan"); params.report_threshold = getIntField(env, settings, "report_threshold"); ALOGD("Initialized common fields %d, %d, %d", params.base_period, params.max_ap_per_scan, params.report_threshold); const char *bucket_array_type = "[Lcom/android/server/wifi/WifiNative$BucketSettings;"; const char *channel_array_type = "[Lcom/android/server/wifi/WifiNative$ChannelSettings;"; jobjectArray buckets = (jobjectArray)getObjectField(env, settings, "buckets", bucket_array_type); params.num_buckets = getIntField(env, settings, "num_buckets"); ALOGD("Initialized num_buckets to %d", params.num_buckets); for (int i = 0; i < params.num_buckets; i++) { jobject bucket = getObjectArrayField(env, settings, "buckets", bucket_array_type, i); params.buckets[i].bucket = getIntField(env, bucket, "bucket"); params.buckets[i].band = (wifi_band) getIntField(env, bucket, "band"); params.buckets[i].period = getIntField(env, bucket, "period_ms"); ALOGD("Initialized common bucket fields %d:%d:%d", params.buckets[i].bucket, params.buckets[i].band, params.buckets[i].period); int report_events = getIntField(env, bucket, "report_events"); params.buckets[i].report_events = report_events; ALOGD("Initialized report events to %d", params.buckets[i].report_events); jobjectArray channels = (jobjectArray)getObjectField( env, bucket, "channels", channel_array_type); params.buckets[i].num_channels = getIntField(env, bucket, "num_channels"); ALOGD("Initialized num_channels to %d", params.buckets[i].num_channels); for (int j = 0; j < params.buckets[i].num_channels; j++) { jobject channel = getObjectArrayField(env, bucket, "channels", channel_array_type, j); params.buckets[i].channels[j].channel = getIntField(env, channel, "frequency"); params.buckets[i].channels[j].dwellTimeMs = getIntField(env, channel, "dwell_time_ms"); bool passive = getBoolField(env, channel, "passive"); params.buckets[i].channels[j].passive = (passive ? 1 : 0); ALOGD("Initialized channel %d", params.buckets[i].channels[j].channel); } } ALOGD("Initialized all fields"); wifi_scan_result_handler handler; memset(&handler, 0, sizeof(handler)); handler.on_scan_results_available = &onScanResultsAvailable; handler.on_full_scan_result = &onFullScanResult; handler.on_scan_event = &onScanEvent; return wifi_start_gscan(id, handle, params, handler) == WIFI_SUCCESS; }
bool FUSE26Util::fillStat(JNIEnv *env, const struct stat *st, jobject statObject) { CSLogTraceEnter("bool FUSE26Util::fillStat(%p, %p, %p)", env, st, statObject); bool ret = false; do { jclass statClass = env->GetObjectClass(statObject); if(statClass == NULL || env->ExceptionCheck() == JNI_TRUE) { CSLogError("Could not get object class!"); if(env->ExceptionCheck()) env->ExceptionDescribe(); break; } jobject st_atimespec; jobject st_mtimespec; jobject st_ctimespec; if(!getObjectField(env, statClass, statObject, "st_atimespec", JAVA_CLASS(TIMESPEC_CLASS), &st_atimespec)) break; if(!getObjectField(env, statClass, statObject, "st_mtimespec", JAVA_CLASS(TIMESPEC_CLASS), &st_mtimespec)) break; if(!getObjectField(env, statClass, statObject, "st_ctimespec", JAVA_CLASS(TIMESPEC_CLASS), &st_ctimespec)) break; if(!setLongField(env, statClass, statObject, "st_dev", st->st_dev)) break; if(!setLongField(env, statClass, statObject, "st_ino", st->st_ino)) break; if(!setLongField(env, statClass, statObject, "st_mode", st->st_mode)) break; if(!setLongField(env, statClass, statObject, "st_nlink", st->st_nlink)) break; if(!setLongField(env, statClass, statObject, "st_uid", st->st_uid)) break; if(!setLongField(env, statClass, statObject, "st_gid", st->st_gid)) break; if(!setLongField(env, statClass, statObject, "st_rdev", st->st_rdev)) break; #if defined(__linux__) || defined(__sun__) if(!FUSE26Util::fillTimespec(env, &(st->st_atim), st_atimespec)) break; if(!FUSE26Util::fillTimespec(env, &(st->st_mtim), st_mtimespec)) break; if(!FUSE26Util::fillTimespec(env, &(st->st_ctim), st_ctimespec)) break; #else if(!FUSE26Util::fillTimespec(env, &(st->st_atimespec), st_atimespec)) break; if(!FUSE26Util::fillTimespec(env, &(st->st_mtimespec), st_mtimespec)) break; if(!FUSE26Util::fillTimespec(env, &(st->st_ctimespec), st_ctimespec)) break; #endif if(!setLongField(env, statClass, statObject, "st_size", st->st_size)) break; if(!setLongField(env, statClass, statObject, "st_blocks", st->st_blocks)) break; if(!setLongField(env, statClass, statObject, "st_blocksize", st->st_blksize)) break; #if !defined(__linux__) && !defined(__sun__) if(!setLongField(env, statClass, statObject, "st_flags", st->st_flags)) break; if(!setLongField(env, statClass, statObject, "st_gen", st->st_gen)) break; #endif env->DeleteLocalRef(st_atimespec); env->DeleteLocalRef(st_mtimespec); env->DeleteLocalRef(st_ctimespec); ret = true; } while(0); CSLogTraceLeave("bool FUSE26Util::fillStat(%p, %p, %p): %d", env, st, statObject, ret); return ret; }
/** * Merges the contents of statObject into the struct stat target. */ bool FUSE26Util::mergeStat(JNIEnv *env, jobject statObject, struct stat *target) { CSLogTraceEnter("bool FUSE26Util::mergeStat(%p, %p, %p)", env, statObject, target); bool res = false; do { //LOG_DEBUG(" - Getting class Stat"); //jclass statClass = env->FindClass(env, "org/catacombae/jfuse/Stat"); jclass statClass = env->GetObjectClass(statObject); if(statClass == NULL || env->ExceptionCheck() == JNI_TRUE) { CSLogError("Could not get object class!"); if(env->ExceptionCheck()) env->ExceptionDescribe(); break; } //LOG_DEBUG(" - statClass: %X", (int)statClass); //LOG_DEBUG(" - Getting field id for st_mode"); jlong jl_dev; jlong jl_ino; jlong jl_mode; jlong jl_nlink; jlong jl_uid; jlong jl_gid; jlong jl_rdev; jobject jl_atimespec; jobject jl_mtimespec; jobject jl_ctimespec; jlong jl_size; jlong jl_blocks; jlong jl_blocksize; jlong jl_flags; jlong jl_gen; if(!getLongField(env, statClass, statObject, "st_dev", &jl_dev)) break; if(!getLongField(env, statClass, statObject, "st_ino", &jl_ino)) break; if(!getLongField(env, statClass, statObject, "st_mode", &jl_mode)) break; if(!getLongField(env, statClass, statObject, "st_nlink", &jl_nlink)) break; if(!getLongField(env, statClass, statObject, "st_uid", &jl_uid)) break; if(!getLongField(env, statClass, statObject, "st_gid", &jl_gid)) break; if(!getLongField(env, statClass, statObject, "st_rdev", &jl_rdev)) break; if(!getObjectField(env, statClass, statObject, "st_atimespec", JAVA_CLASS(TIMESPEC_CLASS), &jl_atimespec)) break; if(!getObjectField(env, statClass, statObject, "st_mtimespec", JAVA_CLASS(TIMESPEC_CLASS), &jl_mtimespec)) break; if(!getObjectField(env, statClass, statObject, "st_ctimespec", JAVA_CLASS(TIMESPEC_CLASS), &jl_ctimespec)) break; if(!getLongField(env, statClass, statObject, "st_size", &jl_size)) break; if(!getLongField(env, statClass, statObject, "st_blocks", &jl_blocks)) break; if(!getLongField(env, statClass, statObject, "st_blocksize", &jl_blocksize)) break; if(!getLongField(env, statClass, statObject, "st_flags", &jl_flags)) break; if(!getLongField(env, statClass, statObject, "st_gen", &jl_gen)) break; struct timespec tmp_st_atimespec, tmp_st_mtimespec, tmp_st_ctimespec; if(!FUSE26Util::mergeTimespec(env, jl_atimespec, &tmp_st_atimespec)) break; if(!FUSE26Util::mergeTimespec(env, jl_mtimespec, &tmp_st_mtimespec)) break; if(!FUSE26Util::mergeTimespec(env, jl_ctimespec, &tmp_st_ctimespec)) break; target->st_dev = jl_dev; target->st_ino = jl_ino; target->st_mode = jl_mode; target->st_nlink = jl_nlink; target->st_uid = jl_uid; target->st_gid = jl_gid; target->st_rdev = jl_rdev; #if defined(__linux__) || defined(__sun__) target->st_atim = tmp_st_atimespec; target->st_mtim = tmp_st_mtimespec; target->st_ctim = tmp_st_ctimespec; #else target->st_atimespec = tmp_st_atimespec; target->st_mtimespec = tmp_st_mtimespec; target->st_ctimespec = tmp_st_ctimespec; #endif target->st_size = jl_size; target->st_blocks = jl_blocks; target->st_blksize = jl_blocksize; #if !defined(__linux__) && !defined(__sun__) target->st_flags = jl_flags; target->st_gen = jl_gen; #endif res = true; } while(0); CSLogTraceLeave("bool FUSE26Util::mergeStat(%p, %p, %p): %d", env, statObject, target, true); return res; }
void Java_ob_android_Stream_stream(JNIEnv *env, jobject obj) { jclass streamClazz = env->GetObjectClass(obj); if(streamClazz == NULL) return; jobject videoPipe, audioPipe; if(!getObjectField(env, obj, "video", "Ljnix/Pipe;", &videoPipe)) return; if(!getObjectField(env, obj, "audio", "Ljnix/Pipe;", &audioPipe)) return; jobject videoInputFD, audioInputFD; if(!getObjectField(env, videoPipe, "input", "Ljava/io/FileDescriptor;", &videoInputFD)) return; if(!getObjectField(env, audioPipe, "input", "Ljava/io/FileDescriptor;", &audioInputFD)) return; jint vfd, afd; if(!getIntField(env, videoInputFD, "descriptor", &vfd)) return; if(!getIntField(env, audioInputFD, "descriptor", &afd)) return; if((videoFile = fdopen(vfd, "rb")) == NULL) { throwException(env, "java/lang/RuntimeException", "Unable to open the video pipe as a file"); return; } logDebug("Video file descriptor opened as a file"); if((audioFile = fdopen(afd, "rb")) == NULL) { throwException(env, "java/lang/RuntimeException", "Unable to open the video pipe as a file"); return; } logDebug("Audio file descriptor opened as a file"); logDebug("Starting to stream"); BasicTaskScheduler* scheduler = BasicTaskScheduler::createNew(); logDebug("Loaded scheduler"); uenv = BasicUsageEnvironment::createNew(*scheduler); logDebug("Loaded environment"); DarwinInjector* injector = DarwinInjector::createNew(*uenv, "streamer"); logDebug("Loaded Darwin injector"); struct in_addr dummyDestAddress; dummyDestAddress.s_addr = 0; Groupsock rtpGroupsockVideo(*uenv, dummyDestAddress, 0, 0); Groupsock rtcpGroupsockVideo(*uenv, dummyDestAddress, 0, 0); Groupsock rtpGroupsockAudio(*uenv, dummyDestAddress, 0, 0); Groupsock rtcpGroupsockAudio(*uenv, dummyDestAddress, 0, 0); logDebug("Created group sockets"); // Create an 'MPEG-4 Video RTP' sink from the RTP 'groupsock': rtpVideoSink = MPEG4ESVideoRTPSink::createNew(*uenv, &rtpGroupsockVideo, 96); rtpAudioSink = AMRAudioRTPSink::createNew(*uenv, &rtpGroupsockVideo, 97); logDebug("Created a video sink"); logDebug("Created an audio sink"); logDebug("Beginning to play"); play(); if(!awaitConfigInfo(rtpVideoSink)) { *uenv << "Failed to get MPEG-4 'config' information from input file: " << uenv->getResultMsg() << "\n"; exit(1); } // Create (and start) a 'RTCP instance' for this RTP sink: const unsigned estimatedSessionBandwidthVideo = 200; // in kbps; for RTCP b/w share const unsigned maxCNAMElen = 100; unsigned char CNAME[maxCNAMElen+1]; gethostname((char*)CNAME, maxCNAMElen); CNAME[maxCNAMElen] = '\0'; // just in case logDebug((const char*)CNAME); RTCPInstance* videoRTCP = RTCPInstance::createNew(*uenv, &rtcpGroupsockVideo, estimatedSessionBandwidthVideo, CNAME, rtpVideoSink, NULL /* we're a server */); RTCPInstance* audioRTCP = RTCPInstance::createNew(*uenv, &rtcpGroupsockAudio, estimatedSessionBandwidthVideo, CNAME, rtpAudioSink, NULL /* we're a server */); // Note: This starts RTCP running automatically // Add these to our 'Darwin injector': injector->addStream(rtpVideoSink, videoRTCP); injector->addStream(rtpAudioSink, audioRTCP); if(!injector->setDestination( "192.168.1.100", "hero.sdp", "herosession", "", 554, "broadcast", "broadcast")) { *uenv << "injector->setDestination() failed: " << uenv->getResultMsg() << "\n"; exit(1); } *uenv << "Play this stream (from the Darwin Streaming Server) using the URL:\n" << "\trtsp://" << "localhost" << "/" << "test.sdp" << "\n"; uenv->taskScheduler().doEventLoop(); }