CM7 HD Recording (by hhcat) - Milestone XT720 Android Development

Hhcat post that but unfortunally he can't post in this thread so, I forward his post.
hhcat said:
This post is better to be in xt720 Dev board. But it is a pity that I don't have the privilege to post in that board now. So anybody who kindly help forward to the dev board would be great appreicated.
For quite a long time, we sufferred to HD record issue in CM7. And I spent some days inveistigaing this issue and fortunatelly got some interesting findings to share.
1. 720p HD recording fail becasue of wrong width and height parameter pass to function createOverlay in libsurfaceflinger.so.
02-13 17:38:12.030: D/TIOverlay(1876): overlay_createOverlay:IN w=768 h=432 format=99
02-13 17:38:12.030: I/Overlay(1876): v4l2_overlay_init:: w=480 h=854
02-13 17:38:12.030: I/Overlay(1876): v4l2_overlay_init:: w=768 h=432
02-13 17:38:12.030: I/Overlay(1876): v4l2_overlay_init:: w=768 h=432
Here we see, the paramter passed to createOverly is (768,432). And in comparison with 2.2 stocked Rom, the right parameter should be (1280,720) for HD recording.
2. The wrong width/height parameter is set in libcameraservice.so. Perhaps CM7 forbids HD recording...
02-13 17:38:12.030: D/CameraService(1540): Changing overlay dimensions to 768X432 for 720p recording.
And double check by open libcameraservice.so, we found the matched words in the above at the address of 0x000ae00h.
Proposed solution:
If someone could kindly help modify the code to comment the piece of code and build a new libcameraservice.so, we may have chance to bring HD recording back.
Click to expand...
Click to collapse

corresponding code
frameworks/base/services/camera/libcameraservice/CameraService.cpp
Code:
#ifdef BOARD_USE_FROYO_LIBCAMERA
struct camera_size_type {
int width;
int height;
};
static const camera_size_type preview_sizes[] = {
{ 1280, 720 }, // 720P
{ 768, 432 },
};
#endif
.........
..........
#ifdef BOARD_USE_FROYO_LIBCAMERA
//for 720p recording , preview can be 800X448
if(w == preview_sizes[0].width && h==preview_sizes[0].height){
LOGD("Changing overlay dimensions to 768X432 for 720p recording.");
w = preview_sizes[1].width;
h = preview_sizes[1].height;
}
#endif
as you findings match my digging (e.g. if videorecording is set to 1280x720, no overlay is show on the display, however some file is generated)
i changed to
Code:
#ifdef BOARD_USE_FROYO_LIBCAMERA
//for 720p recording , preview can be 800X448
if(w == preview_sizes[0].width && h==preview_sizes[0].height){
LOGD("Changing overlay dimensions to 768X432 for 720p recording.");
w = preview_sizes[0].width;
h = preview_sizes[0].height;
}
#endif
will give feedback when have time to test....
p.s. will put again relevant information from the camera blobs....
Code:
preview-size-values=176x144,320x240,352x288,640x480,720x480,720x576,800x448,848x480,1280x720
video-size-values=176x144,320x240,352x288,640x480,720x480,720x576,1280x720

Related

RIL

XDA Developers,
Years ago I downloaded the RIL .dll and API from this site. Then it was only half complete and I had to patch it my self.
I am sure development has been completed since then.
Can anybody tell me if RIL is still maintained by this site? In which case, where can I get it?
Specifically I need signal quality on XDA II upwards. If anybody can help me?
Kind Regards,
Ben
After posting, my text RIL was shown with a link to most of the information.
There is one think I can't understand. The stucture returned as as follows:
int nMinSignalStrength; // @field TBD
int nMaxSignalStrength; // @field TBD
int nLowSignalStrength; // @field TBD
int nHighSignalStrength; // @field TBD
Which have the values (On XDA IIs) of -113, -51, -110, -60
Would any member know what the meaning of these values is?
I have then tried to convert the quality to a percentage. But the percentage always reads way to high, or zero.
My guess is that these are DB and therefore logarithmic. Would any member know how to convert to a linar scale?
My guess is something like: log10(n / 3) where n is any of the above or retuned figure.
Any ideas would be very useful!
Regards, Ben.
Hi,
Code:
HRESULT RIL_GetSignalQuality(
HRIL hRil // @parm handle to RIL instance returned by <f RIL_Initialize>
);
returns the following structure:
Code:
typedef struct rilsignalquality_tag {
DWORD cbSize; // @field structure size in bytes
DWORD dwParams; // @field indicates valid parameters
int nSignalStrength; // @field TBD
int nMinSignalStrength; // @field TBD
int nMaxSignalStrength; // @field TBD
DWORD dwBitErrorRate; // @field bit error rate in 1/100 of a percent
int nLowSignalStrength; // @field TBD
int nHighSignalStrength; // @field TBD
} RILSIGNALQUALITY, *LPRILSIGNALQUALITY;
Why don't you just use nSignalStrength? Sounds pretty simple and linear to me? Nothing to calculate...
In trying to make my posting simple. I think I forgot to clarify my problem
First is the problem that the nSignalStrength falls between two values.
But there are two fields it can fall between:
nMinSignalStrength <= nSignalStrength <= nMaxSignalStrength
nLowSignalStrength <= nSignalStrength <= nHighSignalStrength
Which one should be used? Why are there two?
Secondly, I want to show a percentage result between one of the above. But these figures are, I belive, Decibels (BD). Each 3 DB = a doubling of the value. So 1 = 10%, 4 = 20%, 7 = 40% etc...
Therefore a liniar percent placement of nSignalStrengh tells me nothing. Most values are close to Max, and then suddenly zero.
My math is a little rusty I was hoping somebody may have a nice function for returning the linear range from the logarithmic rageā€¦.
Thanks again to any members who can offer some help
Ben
Hmm... but what if min and max are just values currently encountered in your local cell? When you move to another cell you may receive different min/max values. Or maybe these are the values of the farest and nearest cell? I don't know either, but your explanation of min/max sounds worse to me than does mine...
This could be correct. The values I have are on my XDA IIs using O2 are:
Min -113
Low -110
High -60
Max -51
Therefore:
Min < Low < nSignalStrength < High < Max
So I am using Low = 0% and High = 100%. But this returnes figures of above 50% when signal is quite low.
I think the linear conversion is exp(value / 3)
Therefore percent is:
percent = (exp(nSignalStrength / 3) - exp(Low / 3)) / (exp(high / 3) - exp(Low / 3)) * 100;
Which seems to give better figures. But I am not sure how accurate it is..
Any experts on signal quality out there, I'd love to hear from them!
Ben
If anybody is following this thread, this *seems* to return a good percentage for signal quality. I am not sure of the quality or accuracy. But it works
static double dValue, dMax;
dValue = (int)data->nSignalStrength; // (int) to convert twos complement signed integer correctly.
dMax = (int)data->nHighSignalStrength; // (int) to convert twos complement signed integer correctly.
dValue -= (int)data->nLowSignalStrength;
dMax -= (int)data->nLowSignalStrength;
dValue = pow(dValue / -3.0, 2);
dMax = pow(dMax / -3.0, 2);
dValue /= dMax;
dValue *= 100;
if (dValue > 100) dValue = 100; // never
if (dValue < 0) dValue = 0; // never
Regards,
Ben
Hi there, i've been following this thread with interest I have a very limited knowlege of C++ but not even on the PPC.
Would you mind attaching or even PMing your cpp so i could possibly learn more ?
I find i learn more by examples, and am quite interested in making an application that can disable the radio then re-enable it after a set ammount of time (so i can swap between sims, i have a dual sim adapter)
Best thing to do is follow the sample code supplied by these nice gues from xda-developers, by clicking on this RIL link.
BUT replace the ril.h in the .zip archive with the ril.h you will find from the link.
(nb: if the author of this .zip archive is reading, it's way out of date to the ril.h on this site. ps, hows the ril development going?)
If you get the sample code working, this will give you some idea of what is possible. Your options may not be possible. But look at the ril.h and the functions listed. If one of them does what you want, give it a go.
Regards,
Ben

Simulate Button Click

Hi,
I am trying to simulate a PictureBox.Click event. I have searched these forums and the ones on MSDN with many different combinations of search terms.
However I cannot find anything!
Basically what I am trying to achieve is to fire the picturebox's click event from within my code. What I have read so far seems to indicate that I need to make a call to SendMessage (COM interop?) to actually make windows perform the click.
This is for the compact framework version 1.0.
Any help you can give would be great because this is all very new to me, I'm a web application developer by trade so i'm a fish out of water on this one!
OK, the other method that I am investigating is the use of the mouse_event as demonstrated in this article by Daniel Moth.
However I am struggling to find the namespace Win32Api anywhere in the framework so I'm struggling with that also.
*Update*
I have been able to simulate a click using mouse_event in a call to the coredll using the following code:
Code:
[DllImport("coredll")]
static extern bool SetCursorPos(int X, int Y);
[DllImport("coredll")]
static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);
[Flags]
public enum MouseEventFlags
{
LEFTDOWN = 0x00000002,
LEFTUP = 0x00000004,
MIDDLEDOWN = 0x00000020,
MIDDLEUP = 0x00000040,
MOVE = 0x00000001,
ABSOLUTE = 0x00008000,
RIGHTDOWN = 0x00000008,
RIGHTUP = 0x00000010
}
bool tempVal = SetCursorPos(x, y);
mouse_event((uint)MouseEventFlags.LEFTDOWN, 0, 0, 0, 0);
mouse_event((uint)MouseEventFlags.LEFTUP, 0, 0, 0, 0);
however I have one outstanding problem (that I know of!).
I am struggling to capture the corrext X and Y co-ordinates of the control. I have tried many different methods and they all return values of 0 for both axis.
How do you guys do it?
Many Thanks
I haven't answered till now since I don't know .NET
But since you found your way to using native APIs I think I can help you.
This is how I would do it in C/C++:
Code:
RECT wndRect; //this is a structure that contains window top, left, bottom and right coordinates.
GetWindowRect(FindWind(L"[I]window class[/I]", L"[I]window name[/I]"), &wndRect);
x = wndRect.left + 1; //add 1 to window position to make sure the click is inside
y = wndRect.top + 1;
GetWindowRect returns the window position in screen coordinates for top left and bottom right corners.
For FindWindow to work you need to know the class and name of the window you want to find. You can find them using a utility called SPY++ which comes with any Microsoft C++ compiler.
The class is window type (so it will probably be something like 'PictureBox' or 'Image') and window name is most likely blank.
Hope this helps.
Thanks fo your help
I don't know if your code would have done the trick or not but I managed to work my way through the different class definitions to find what i needed.
Code:
int x = selectedButton.PointToScreen(selectedButton.Bounds.Location).X + 2;
int y = selectedButton.PointToScreen(selectedButton.Bounds.Location).Y + 2;
This still doesn't work but I really don't have time to work out why, all I know is that the call to SetCursorPos() returns false. I know the mouse_event code works because if I position the cursor over the Start button it opens the menu.
Time is of an essence so for now I'm just going to have to drop this and pray that I have time to finish this when towards the end of my project.
/me thinks writing my first Mobile 5.0 application in 4 days (I'm a web application developer by trade) was bad planning on the management's fault anyway
Thanks for your input though
use this method signature:
[DllImport("coredll")]
public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
int instead of uint or long.
For me it worked.

GetOrientation problems

It has been a while since I wrote a program for the last time, and when I got my Desire I decided it would be a good moment to start again.
After a few very simple test programs I decided to go a little further and try to access the sensors.
With a little research I found out I had to use public static float[] getOrientation (float[] R, float[] values) . This is what I found in the documentation:
float[] android.hardware.SensorManager.getOrientation(float[] R, float[] values)
public static float[] getOrientation (float[] R, float[] values)
Since: API Level 3
Computes the device's orientation based on the rotation matrix.
When it returns, the array values is filled with the result:
values[0]: azimuth, rotation around the Z axis.
values[1]: pitch, rotation around the X axis.
values[2]: roll, rotation around the Y axis.
All three angles above are in radians and positive in the counter-clockwise direction.
Parameters
R rotation matrix see getRotationMatrix(float[], float[], float[], float[]).
values an array of 3 floats to hold the result.
Returns
The array values passed as argument.
Click to expand...
Click to collapse
I didn't understand the use of float[] R part, so I decided to just give null as argument
Code:
float[] values = new float[3];
SensorManager.getOrientation(null, values);
TextView xText = (TextView) findViewById(R.id.TextView02);
TextView yText = (TextView) findViewById(R.id.TextView03);
TextView zText = (TextView) findViewById(R.id.TextView04);
xText.setText(String.valueOf(values[0]));
yText.setText(String.valueOf(values[1]));
zText.setText(String.valueOf(values[2]));
But my program fails when it comes to the line where I call getOrientation, so my guess is I shouldn't give null as argument. How should I use getOrientation()?

[Q] In-App Video Recording

I came across a service named "TestFairy", and I am interested in some of it's features, but it's TOS does not agree with my application. So, I wanted to ask if anyone knows how one could implement the In-App recording feature used in TestFairy in an Android application without root. I have already done some Googling to no avail, and I am just starting to make Android apps, so I don't know how this can be done.
You can see what feature I am talking about at testfairy.com by clicking "Demo" at the top or watching their intro video.
Edit: It would appear that it is implemented by screenshots in rapid succession. How could I do this or (better yet) just record a video of just my application without root?
If you only want to record the video on your device, you could use the new screenrecord shell command in KitKat
https://developer.android.com/about/versions/kitkat.html#44-screen-recording
painlessDeath said:
If you only want to record the video on your device, you could use the new screenrecord shell command in KitKat
https://developer.android.com/about/versions/kitkat.html#44-screen-recording
Click to expand...
Click to collapse
Thank you for mentioning it, but this doesn't work without root or without a computer, and I am trying to support devices down to Gingerbread, not just KitKat.
Ohh, I thought you just wanted to create a video demo of your app.
To add support for recording video for your own app, you would take the root view of your app, and add the screenshots of the view periodically to a video.
Example code
Code:
// The root view you want to record.
View rootView = getWindow().getDecorView();
rootView.setDrawingCacheEnabled(true);
// Record the view in a separate thread.
new AsyncTask<View, Void, Void>() {
@Override
protected Void doInBackground(View... params) {
View source = params[0];
long time;
int fps = 30;
long frameDuration = 1000 / fps;
while (!isCancelled()) {
time = System.currentTimeMillis();
addBitmpToVideo(source.getDrawingCache(), frameDuration);
Thread.sleep(frameDuration);
}
return null;
}
}.execute(rootView);
You would have to implement addBitmpToVideo.
You could either user ffmpeg for this or if you only want ICS+ support, you could try using the hidden videoeditor API
http://stackoverflow.com/questions/14197757/android-video-editor-classes
painlessDeath said:
Ohh, I thought you just wanted to create a video demo of your app.
To add support for recording video for your own app, you would take the root view of your app, and add the screenshots of the view periodically to a video.
Example code
Code:
// The root view you want to record.
View rootView = getWindow().getDecorView();
rootView.setDrawingCacheEnabled(true);
// Record the view in a separate thread.
new AsyncTask<View, Void, Void>() {
@Override
protected Void doInBackground(View... params) {
View source = params[0];
long time;
int fps = 30;
long frameDuration = 1000 / fps;
while (!isCancelled()) {
time = System.currentTimeMillis();
addBitmpToVideo(source.getDrawingCache(), frameDuration);
Thread.sleep(frameDuration);
}
return null;
}
}.execute(rootView);
You would have to implement addBitmpToVideo.
You could either user ffmpeg for this or if you only want ICS+ support, you could try using the hidden videoeditor API
http://stackoverflow.com/questions/14197757/android-video-editor-classes
Click to expand...
Click to collapse
Thanks! I will try this out when I get the chance.

How to use setNextMediaPlayer with videos?

Hi all.
I'm trying to use setNextMediaPlayer function with 2 video files:
http://developer.android.com/refere...setNextMediaPlayer(android.media.MediaPlayer)
Code:
mp0 = new MediaPlayer();
mp1 = new MediaPlayer();
mp0.setDataSource("/mnt/sdcard/video1.mp4");
mp0.setDisplay(holder); // surface holder set
mp0.prepare();
mp1.setDataSource("/mnt/sdcard/video2.mp4");
//mp1.setDisplay(holder); // surface holder NOT set because I get an error (width 0, height 0) in video size changed event
mp1.prepare();
mp0.setNextMediaPlayer( mp1 );
mp0.start();
It this way I see the first video, it finishes and then I can only listen the audio track of the second video...
I tried also to call "setNextMediaPlayer" in "onPrepared" event listener, same result.
Any idea?

Categories

Resources