[android-developers] Re: seeking with av_seek_frame or url_seek

2011-04-22 Thread emymrin
I guess new position must be expressed in stream time units:

// iNewPosition is in seconds
int64_t timeStamp = iNewPosition * pFormatCtx-streams[iStreamIndex]-
time_base.den;
av_seek_frame(pFormatCtx, iStreamIndex, timeStamp, AVSEEK_FLAG_ANY);

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What exactly is the obtainBuffer in an AudioTrack?

2011-03-22 Thread emymrin
 how can I prevent (or at least minimize) the delay

When AudioTrack object is created, buffer size is passed into a
constructor among other parameters.
AudioTrack won't start playing until you write at least that amount of
data into it.
I presume that in your case chosen buffer size is siginificantly
larger than AudioTrack.getMinBufferSize.
That's why it doesn't start playing when the first data portion is
written.

 famous obtainBuffer timed out (is the CPU pegged?) warning

It appears to the worst in 1.5 emulator.
Much better in Android 2+ emulator (shown maybe once per 4 seconds).
I have never seen this warning when testing on a real device.
My suggestion is to ignore it.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Menu typeface

2011-03-20 Thread emymrin
Try the following ugly technique to customize your options menu:

getLayoutInflater().setFactory(new Factory() {
public View onCreateView (String name, final Context context,
AttributeSet attrs) {

if(name.equalsIgnoreCase(com.android.internal.view.menu.IconMenuItemView))
{
final View view = getLayoutInflater().createView(name, 
null,
attrs);
// Apply custom style after standard one gets applied
new Handler().post(new Runnable() {
public void run() {
TextView text = (TextView) view;
text.setTextAppearance(context, 
R.style.your_text_style);
}
});
return view;
}
return null;
}
});


On 20 мар, 17:25, Kamil kmichal...@gmail.com wrote:
 Hi,
 Is there any way to change menu typeface to bold?

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Not able to receive UDP Data

2011-03-18 Thread emymrin
UDP works well on emulators and devices.

DatagramSocket socket = new DatagramSocket(port);
byte[] data = new byte[1000];
DatagramPacket datagram = new DatagramPacket(data, 0, data.length,
null, 0);
socket.receive(datagram);


On 18 мар, 03:20, Miguel Morales therevolti...@gmail.com wrote:
 I've read people on the internet recommending to use UDP for game networking
 on Android.  However, when I was attempting to implement it using my real G1
 device on Tmobile.  However, I didn't have any success.  I don't really
 recall having tried it on the emulator, but I probably did.
 If anyone had any luck implementing a udp server on an Android device, I'd
 be interesting to hear how.

 On Thu, Mar 17, 2011 at 5:09 PM, Indicator Veritatis mej1...@yahoo.comwrote:









  Step 1: make sure you can receive TCP. Step 2: open the right UDP
  ports on your firewall and run Wireshark if you are still not
  receiving anything. Debug based on what you see.Step 3: get it working
  on a real phone using WiFi on the same local network as your emulator.

  If it then fails when you use your phone carrier's data service, the
  problem is almost certainly their firewall.

  On Mar 17, 9:19 am, Scott iamavinash...@gmail.com wrote:
   Hi

   I am trying to receive UDP data sent from server to my android
   emulator client. But i am not able to receive the UDP data in my
   android client application which is running on emulator.
   packet = new DatagramPacket(buf, buf.length);
   socket.receive(packet);

   1) Can you please let me know how to fix it and receive UDP data on
   emulator from server application running on some other system.

   2) Will i face same problem in receving UDP data if i run my client on
   the Android hardware/Android based mobile.

   3) Will i face similar problem in receving the TCP based data when
   running the application on the Android Emulator.

   Kindly pleas guide/help me to get the answers to the above queries.

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 ~ Jeremiah:9:23-24
 Android 2D MMORPG:http://solrpg.com/http://www.youtube.com/user/revoltingx

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: avcodec_decoder_find problem

2011-02-06 Thread emymrin
For all I know calling avcodec_find_decoder with hardcoded codec id is
not a good idea.
What if particular stream contains data which was encoded with a
different codec?
av_open_input_file is the one I would expect to block under certain
conditions (bad URLProtocol implementation, for example), not
avcodec_open.
Have you built FFmpeg yourself?


On 6 фев, 14:24, cervello eceooz...@gmail.com wrote:
 thank you very much...

 I did it just like below and it works..but I can't tell that it's
 completely true right now because I still continue to control my
 code..
 but thanks again

 // Find the decoder for the video stream
         pCodec=avcodec_find_decoder(CODEC_ID_H263);

         if(pCodec==NULL) {
           fprintf(stderr, Unsupported codec!\n);
           return -1; // Codec not found
         }
         pCodecCtx = avcodec_alloc_context();
         // Open codec
         if(avcodec_open(pCodecCtx, pCodec)0)
           return -1; // Could not open codec

 On Feb 5, 9:15 pm, emymrin emym...@gmail.com wrote:







  Try to instrument avcodec_open and anything that it calls with
  __android_log_print to get an idea about what is wrong.

  On 5 фев, 19:03, cervello eceooz...@gmail.com wrote:

   I'm trying to decode a video but in my code I think there is a problem
   about avcodec_find decoder().. I control it with log_message and on
   logcat there is here1 but there isn't here2 .. So I think there is
   a problem with avcodec_find_decoder...
   Can anyone any idea?? Please help me, Thanks

   And how can I describe pCodecCtx-codec_id.. With %d and %s It didn't
   work.

   char info[40];
   sprintf(info,i degeri = %d,pCodecCtx-codec_id);
   log_message(info);

   *Here is my code**

   jint Java_com_test_Test_takePics(JNIEnv* env, jobject javaThis) {
   int framecount;
   log_message(Fonka girdi);
   //OPENING FILE** 
   AVFormatContext *pFormatCtx;
   unsigned char r, g, b;
   int i,j;

   char* filename = /sdcard/do-beer-not-drugs.3gp;
   av_register_all();

   // Open video file
   if(av_open_input_file(pFormatCtx, filename, NULL, 0, NULL)!=0)
   return -1; // Couldn't open file

   // Retrieve stream information
   if(av_find_stream_info(pFormatCtx)0)
   return -1; // Couldn't find stream information

   // Dump information about file onto standard error
   dump_format(pFormatCtx, 0, filename, 0);
   framecount = pFormatCtx-streams[0]-nb_frames;
   hist = malloc(framecount*sizeof(int*));

   for (j = 0; j  framecount; ++j) {
   hist[j] = malloc(sizeof(int)*64); // this is because we use 64-bin
   histogram}

   for (i = 0; i  framecount; i++) {
   for (j = 0; j  64; j++) {
   hist[i][j] = 0;

   }
   }

   AVCodecContext *pCodecCtx;

   // Find the first video stream
   int videoStream;
   videoStream=-1;
   /*char info[40];
   sprintf(info,i degeri = %d,pFormatCtx-nb_streams);
   log_message(info);*/
   for(i=0; ipFormatCtx-nb_streams; i++){
   if(pFormatCtx-streams[i]-codec-codec_type==CODEC_TYPE_VIDEO) {
   videoStream=i;
   break;

   }}

   if(videoStream==-1)
   return -1; // Didn't find a video stream

   AVCodec *pCodec;
   char info[40];
   sprintf(info,i degeri = %d,pCodecCtx-codec_id);
   log_message(info);

   // Find the decoder for the video stream
   pCodec=avcodec_find_decoder(pCodecCtx-codec_id);

   if(pCodec==NULL) {
   fprintf(stderr, Unsupported codec!\n);
   return -1; // Codec not found}

   log_message(here1);
   // Open codec
   if(avcodec_open(pCodecCtx, pCodec)0)
   return -1; // Could not open codec
   log_message(here2);
   // Get a pointer to the codec context for the video stream
   pCodecCtx=pFormatCtx-streams[videoStream]-codec;

   //STORING THE DATA** **

   AVFrame *pFrame;

   // Allocate video frame
   pFrame=avcodec_alloc_frame();

   // Allocate an AVFrame structure
   AVFrame *pFrameRGB;
   pFrameRGB=avcodec_alloc_frame();

   if(pFrameRGB==NULL)
   return -1;

   uint8_t *buffer;
   int numBytes;
   // Determine required buffer size and allocate buffer
   numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx-width,
   pCodecCtx-height);
   buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

   // Assign appropriate parts of buffer to image planes in pFrameRGB
   // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
   // of AVPicture
   avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
   pCodecCtx-width, pCodecCtx-height);

   //READING DATA** *

   int frameFinished;
   AVPacket packet;

   i=0;
   while(av_read_frame(pFormatCtx, packet)=0) {
   // Is this a packet from the video stream?
   if(packet.stream_index==videoStream) {
   // Decode video frame
   avcodec_decode_video(pCodecCtx, pFrame, frameFinished,
   packet.data, packet.size);

   // Did we get a video frame?
   if(frameFinished) {
   static struct SwsContext *img_convert_ctx;

   // Convert the image into RGB format

[android-developers] Re: avcodec_decoder_find problem

2011-02-05 Thread emymrin
Try to instrument avcodec_open and anything that it calls with
__android_log_print to get an idea about what is wrong.

On 5 фев, 19:03, cervello eceooz...@gmail.com wrote:
 I'm trying to decode a video but in my code I think there is a problem
 about avcodec_find decoder().. I control it with log_message and on
 logcat there is here1 but there isn't here2 .. So I think there is
 a problem with avcodec_find_decoder...
 Can anyone any idea?? Please help me, Thanks

 And how can I describe pCodecCtx-codec_id.. With %d and %s It didn't
 work.

 char info[40];
 sprintf(info,i degeri = %d,pCodecCtx-codec_id);
 log_message(info);

 *Here is my code**

 jint Java_com_test_Test_takePics(JNIEnv* env, jobject javaThis) {
 int framecount;
 log_message(Fonka girdi);
 //OPENING FILE** 
 AVFormatContext *pFormatCtx;
 unsigned char r, g, b;
 int i,j;

 char* filename = /sdcard/do-beer-not-drugs.3gp;
 av_register_all();

 // Open video file
 if(av_open_input_file(pFormatCtx, filename, NULL, 0, NULL)!=0)
 return -1; // Couldn't open file

 // Retrieve stream information
 if(av_find_stream_info(pFormatCtx)0)
 return -1; // Couldn't find stream information

 // Dump information about file onto standard error
 dump_format(pFormatCtx, 0, filename, 0);
 framecount = pFormatCtx-streams[0]-nb_frames;
 hist = malloc(framecount*sizeof(int*));

 for (j = 0; j  framecount; ++j) {
 hist[j] = malloc(sizeof(int)*64); // this is because we use 64-bin
 histogram}

 for (i = 0; i  framecount; i++) {
 for (j = 0; j  64; j++) {
 hist[i][j] = 0;

 }
 }

 AVCodecContext *pCodecCtx;

 // Find the first video stream
 int videoStream;
 videoStream=-1;
 /*char info[40];
 sprintf(info,i degeri = %d,pFormatCtx-nb_streams);
 log_message(info);*/
 for(i=0; ipFormatCtx-nb_streams; i++){
 if(pFormatCtx-streams[i]-codec-codec_type==CODEC_TYPE_VIDEO) {
 videoStream=i;
 break;

 }}

 if(videoStream==-1)
 return -1; // Didn't find a video stream

 AVCodec *pCodec;
 char info[40];
 sprintf(info,i degeri = %d,pCodecCtx-codec_id);
 log_message(info);

 // Find the decoder for the video stream
 pCodec=avcodec_find_decoder(pCodecCtx-codec_id);

 if(pCodec==NULL) {
 fprintf(stderr, Unsupported codec!\n);
 return -1; // Codec not found}

 log_message(here1);
 // Open codec
 if(avcodec_open(pCodecCtx, pCodec)0)
 return -1; // Could not open codec
 log_message(here2);
 // Get a pointer to the codec context for the video stream
 pCodecCtx=pFormatCtx-streams[videoStream]-codec;

 //STORING THE DATA** **

 AVFrame *pFrame;

 // Allocate video frame
 pFrame=avcodec_alloc_frame();

 // Allocate an AVFrame structure
 AVFrame *pFrameRGB;
 pFrameRGB=avcodec_alloc_frame();

 if(pFrameRGB==NULL)
 return -1;

 uint8_t *buffer;
 int numBytes;
 // Determine required buffer size and allocate buffer
 numBytes=avpicture_get_size(PIX_FMT_RGB24, pCodecCtx-width,
 pCodecCtx-height);
 buffer=(uint8_t *)av_malloc(numBytes*sizeof(uint8_t));

 // Assign appropriate parts of buffer to image planes in pFrameRGB
 // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
 // of AVPicture
 avpicture_fill((AVPicture *)pFrameRGB, buffer, PIX_FMT_RGB24,
 pCodecCtx-width, pCodecCtx-height);

 //READING DATA** *

 int frameFinished;
 AVPacket packet;

 i=0;
 while(av_read_frame(pFormatCtx, packet)=0) {
 // Is this a packet from the video stream?
 if(packet.stream_index==videoStream) {
 // Decode video frame
 avcodec_decode_video(pCodecCtx, pFrame, frameFinished,
 packet.data, packet.size);

 // Did we get a video frame?
 if(frameFinished) {
 static struct SwsContext *img_convert_ctx;

 // Convert the image into RGB format
 if(img_convert_ctx == NULL) {
 int w = pCodecCtx-width;
 int h = pCodecCtx-height;

 img_convert_ctx = sws_getContext(w, h,
 pCodecCtx-pix_fmt,
 w, h, PIX_FMT_RGB24, SWS_BICUBIC,
 NULL, NULL, NULL);
 if(img_convert_ctx == NULL) {
 fprintf(stderr, Cannot initialize the conversion context!\n);
 exit(1);}
 }

 int ret = sws_scale(img_convert_ctx, pFrame-data, pFrame- linesize,
 0, pCodecCtx-height, pFrameRGB-data, pFrameRGB-linesize);

 for (j = 0; j  3*pCodecCtx-height*pCodecCtx-width -3; j++) {
 r = (unsigned char) pFrameRGB-data[0][j];
 g = (unsigned char) pFrameRGB-data[0][j+1];
 b = (unsigned char) pFrameRGB-data[0][j+2];

 r = (unsigned char) ((r  2)  0x30);
 g = (unsigned char) ((g  4)  0x0C);
 b = (unsigned char) ((b  6)  0x03);

 unsigned char h = (unsigned char)(r|g|b);
 hist[i][h]++;

 }

 // Save the frame to sdcard
 SaveFrame(pFrameRGB, pCodecCtx-width, pCodecCtx-height, ++i);

 }
 }

 // Free the packet that was allocated by av_read_frame
 av_free_packet(packet);

 }

 // Free the RGB image
 av_free(buffer);
 av_free(pFrameRGB);

 // Free the YUV frame
 av_free(pFrame);

 // Close the codec
 avcodec_close(pCodecCtx);

 // Close the video file
 av_close_input_file(pFormatCtx);

 int keyframecount;
 framecount=i;
 

[android-developers] Re: CountDownTimer doen't work during device in deep sleep?

2010-12-23 Thread emymrin
Consider using AlarmManager.

On 23 дек, 01:54, optimusgeek choongb...@gmail.com wrote:
 I use CountDownTimer for counting 24hours with 1minute interval.
 but It seems that the onTick() not called when device in deep sleep.
 When I check the millisUntilFinished value after activating device,
 The value was not match first but after few seconds, It show correct
 value.
 I think, when device in deep sleep, handle message from CountDownTimer
 delayed, and if device activated, the last message of CountDownTimer
 sent.
 and after that the millisUntilFinished value is updated.

 Any solution for it? I have to use the CountDownTimer, because I need
 to get the millisUntilFinished value in every 1 minute.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en