예제 #1
0
extern "C" void* j3ResolveStaticStub() {
  JavaThread *th = JavaThread::get();
  void* result = NULL;

  // Lookup the caller of this class.
  vmkit::StackWalker Walker(th);
  ++Walker; // Remove the stub.
  vmkit::FrameInfo* FI = Walker.get();
  assert(FI->Metadata != NULL && "Wrong stack trace");
  JavaMethod* caller = (JavaMethod*)FI->Metadata;

  // Lookup the method info in the constant pool of the caller.
  uint16 ctpIndex = caller->lookupCtpIndex(FI);
  assert(ctpIndex && "No constant pool index");
  JavaConstantPool* ctpInfo = caller->classDef->getConstantPool();
  CommonClass* cl = 0;
  const UTF8* utf8 = 0;
  Signdef* sign = 0;

  ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign);
  UserClass* lookup = cl->isArray() ? cl->super : cl->asClass();
  assert(lookup->isInitializing() && "Class not ready");
  JavaMethod* callee = lookup->lookupMethod(utf8, sign->keyName, true, true, 0);

  // Compile the found method.
  result = callee->compiledPtr();
    
  // Update the entry in the constant pool.
  ctpInfo->ctpRes[ctpIndex] = result;

  return result;
}
예제 #2
0
void JnjvmClassLoader::insertAllMethodsInVM(Jnjvm* vm) {
  JavaCompiler* M = getCompiler();
  for (ClassMap::iterator i = classes->map.begin(), e = classes->map.end();
       i != e; ++i) {
    CommonClass* cl = i->second;
    if (cl->isClass()) {
      Class* C = cl->asClass();
      
      for (uint32 i = 0; i < C->nbVirtualMethods; ++i) {
        JavaMethod& meth = C->virtualMethods[i];
        if (!isAbstract(meth.access) && meth.code) {
          JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")
            JavaStaticMethodInfo(0, meth.code, &meth);
          vm->StaticFunctions.addMethodInfo(MI, meth.code);
          M->setMethod(&meth, meth.code, "");
        }
      }
      
      for (uint32 i = 0; i < C->nbStaticMethods; ++i) {
        JavaMethod& meth = C->staticMethods[i];
        if (!isAbstract(meth.access) && meth.code) {
          JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo")
            JavaStaticMethodInfo(0, meth.code, &meth);
          vm->StaticFunctions.addMethodInfo(MI, meth.code);
          M->setMethod(&meth, meth.code, "");
        }
      }
    }
  }
}
예제 #3
0
void Failover::GetInformationAboutFromAllOtherServer( vector<string> DeviceIP, const char * DID ){

	CommonClass * commFunc = new CommonClass();
	char xmlData[SIZEOFCHARARRAYBIGGER];
	CreateFailOverXml(xmlData);
	//cout<<"\nStart Interaction---->"<<xmlData<<endl;
	for ( int i = 0 ; i < (int)DeviceIP.size() ; i++ ){
		commFunc->CreateConnectionClient((char*)DeviceIP[i].c_str(),tcpSocketPortNumber,xmlData);
	}
}
예제 #4
0
/* called when a new media pipeline is constructed. We can query the
 * pipeline and configure our appsrc */
void ReStream::media_configure_feature (GstRTSPMediaFactory * factory, GstRTSPMedia * media, gpointer user_data)
{
	try{
		GstElement *element, *appsrc;
		struct MyContext *ctx  = (struct MyContext *)user_data;

		element = gst_rtsp_media_get_element (media);

		appsrc = gst_bin_get_by_name_recurse_up (GST_BIN (element), "mysrc");

		gst_util_set_object_arg (G_OBJECT (appsrc), "format", "time");
		g_object_set (G_OBJECT (appsrc), "caps",
				gst_caps_new_simple ("video/x-raw",
						"format", G_TYPE_STRING, "BGR",
						"width", G_TYPE_INT, ctx->width,
						"height", G_TYPE_INT,ctx->height,
						"framerate", GST_TYPE_FRACTION, FPS, 1, NULL),NULL );


		//ctx->white = FALSE;
		ctx->timestamp = 0;
		ctx->buffer =  gst_buffer_new_allocate (NULL, ctx->height * ctx->width*3 , NULL);
		gst_buffer_map (ctx->buffer, &ctx->map, GST_MAP_WRITE);

		/* make sure ther datais freed when the media is gone */
		//g_object_set_data_full (G_OBJECT (media), "my-extra-data", ctx, (GDestroyNotify) g_free);

		g_signal_connect (appsrc, "need-data", (GCallback)need_data_feature, ctx);
		g_signal_connect (media, "unprepared", (GCallback)unprepared_feature, ctx);
		if ( ISDEBUG )
			cout<<"media prepared_feature\n";
		gst_object_unref (appsrc);
		gst_object_unref (element);
	}
	catch(Exception &e){
		CommonClass localcommclass;
		localcommclass.PrintException("ReStream","CV::media_configure_feature",e);
	}
	catch(exception &e){
		CommonClass localcommclass;
		localcommclass.PrintException("ReStream","STD::media_configure_feature",e);
	}
}
예제 #5
0
void ReStream::unprepared_feature (GstRTSPMedia *gstrtspmedia, MyContext* ctx)
{
	try{
		if ( ISDEBUG )
			cout<<"media unprepared_feature "<<endl;
		//cvReleaseCapture(&ctx->cap);
		gst_buffer_unmap (ctx->buffer, &ctx->map);
		gst_buffer_unref(ctx->buffer);
		if ( ISDEBUG )
			cout<<"Successfully released buffers";
	}
	catch(Exception &e){
		CommonClass localcommclass;
		localcommclass.PrintException("ReStream","CV::unprepared_feature",e);
	}
	catch(exception &e){
		CommonClass localcommclass;
		localcommclass.PrintException("ReStream","STD::unprepared_feature",e);
	}

}
예제 #6
0
void ReStream::need_data_feature (GstElement * appsrc, guint unused, gpointer user_data)
{
	try{
		struct MyContext* ctx = (struct  MyContext*)user_data;

		if(ctx==NULL){
			cout<<"ctx is NUll";
			return;
		}
		else
			if ( ISDEBUG )
				cout<<"buffer size"<<gst_buffer_get_size( ctx->buffer );

		guint size,depth,height,width,step,channels;
		GstFlowReturn ret;
		IplImage* img = cvCreateImage(cvSize(ctx->width,ctx->height),IPL_DEPTH_8U,3);
		guchar *data1;

		CvRect rect;
		rect.width =  ctx->width;
		rect.height = ctx->height;
		rect.x = 0;
		rect.y = 0;


		pthread_mutex_lock(&ctx->imgLock);
		while(ctx->image == NULL){
			if ( ISDEBUG )
				cout<<"inside lock ! ImgBuffer is Empty. Please push images.\n";
		}
		cvSetImageROI( ctx->image, rect );
		cvCopy(ctx->image, img );
		cvResetImageROI(ctx->image);
		if ( ISDEBUG )
			cout<<"inside lock ! Copying Image to local Buffer.\n";
		pthread_mutex_unlock(&ctx->imgLock);

		if( img == NULL ){
			cout<<"Failed to fetch the image:( \n";
			return;
		}
		else
		{

			height    = img->height;
			width     = img->width;
			step      = img->widthStep;
			channels  = img->nChannels;
			depth     = img->depth;
			data1      = (guchar *)img->imageData;
			size = height*width*channels;

			memcpy( (guchar *)ctx->map.data, data1,  gst_buffer_get_size( ctx->buffer ) );

			GST_BUFFER_PTS (ctx->buffer) = ctx->timestamp;
			GST_BUFFER_DURATION (ctx->buffer) = gst_util_uint64_scale_int (1, GST_SECOND, FPS);
			ctx->timestamp += GST_BUFFER_DURATION (ctx->buffer);

			g_signal_emit_by_name (appsrc, "push-buffer", ctx->buffer, &ret);

			if (ret != GST_FLOW_OK) {
				if ( ISDEBUG )
					cout<<"error pushing image\n";
			}
			else{
				if ( ISDEBUG )
					cout<<"Successfully pushed\n";
				if(img!=NULL)
					cvReleaseImage(&img);
			}
		}
	}
	catch(Exception &e){
		CommonClass localcommclass;
		localcommclass.PrintException("ReStream","CV::need_data_feature",e);
	}
	catch(exception &e){
		CommonClass localcommclass;
		localcommclass.PrintException("ReStream","STD::need_data_feature",e);
	}
}
예제 #7
0
extern "C" void* j3ResolveVirtualStub(JavaObject* obj) {
  llvm_gcroot(obj, 0);
  JavaThread *th = JavaThread::get();
  UserCommonClass* cl = JavaObject::getClass(obj);
  void* result = NULL;
  
  // Lookup the caller of this class.
  vmkit::StackWalker Walker(th);
  ++Walker; // Remove the stub.
  vmkit::FrameInfo* FI = Walker.get();
  assert(FI->Metadata != NULL && "Wrong stack trace");
  JavaMethod* meth = (JavaMethod*)FI->Metadata;

  // Lookup the method info in the constant pool of the caller.
  uint16 ctpIndex = meth->lookupCtpIndex(FI);
  assert(ctpIndex && "No constant pool index");
  JavaConstantPool* ctpInfo = meth->classDef->getConstantPool();
  CommonClass* ctpCl = 0;
  const UTF8* utf8 = 0;
  Signdef* sign = 0;
  JavaMethod* origMeth = 0;
  ctpInfo->infoOfMethod(ctpIndex, ACC_VIRTUAL, ctpCl, origMeth);

  ctpInfo->resolveMethod(ctpIndex, ctpCl, utf8, sign);
  assert(cl->isSubclassOf(ctpCl) && "Wrong call object");
  UserClass* lookup = cl->isArray() ? cl->super : cl->asClass();
  JavaMethod* Virt = lookup->lookupMethod(utf8, sign->keyName, false, true, 0);

  if (isAbstract(Virt->access)) {
    JavaThread::get()->getJVM()->abstractMethodError(Virt->classDef, Virt->name);
  }

  // Compile the found method.
  result = Virt->compiledPtr(lookup);

  // Update the virtual table.
  assert(lookup->isResolved() && "Class not resolved");
  assert(lookup->isInitializing() && "Class not ready");
  assert(lookup->virtualVT && "Class has no VT");
  assert(lookup->virtualTableSize > Virt->offset && 
         "The method's offset is greater than the virtual table size");
  ((void**)obj->getVirtualTable())[Virt->offset] = result;
  
  if (isInterface(origMeth->classDef->access)) {
    InterfaceMethodTable* IMT = cl->virtualVT->IMT;
    uint32_t index = InterfaceMethodTable::getIndex(Virt->name, Virt->type);
    if ((IMT->contents[index] & 1) == 0) {
      IMT->contents[index] = (word_t)result;
    } else { 
      JavaMethod* Imeth = 
        ctpCl->asClass()->lookupInterfaceMethodDontThrow(utf8, sign->keyName);
      assert(Imeth && "Method not in hierarchy?");
      word_t* table = (word_t*)(IMT->contents[index] & ~1);
      uint32 i = 0;
      while (table[i] != (word_t)Imeth) { i += 2; }
      table[i + 1] = (word_t)result;
    }
  }

  return result;
}