yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I grabbed the two jar files from the phone, added them to my project & included them in the build path but no classes are exposed. I guess I'm not doing this right. Any pointers?
[Galaxy S II Q&A, Help & Troubleshooting] danim:
EDIT: found the files, they're in the /system/framework on the phone.

UKLooney- you need to deodex the files. I attached my deodexed jars to save you the trouble :)

Now, I can add these to my project and Eclipse recognizes the classes, but I get errors -

if adding seccamera.jar, I get a compilation error "Conversion to Dalvik format failed with error 1"

with only secmediarecorder.jar added, installation of the app failed with error: "Installation error: INSTALL_FAILED_DEXOPT". the logat shows:

ERROR/installd(2583): dexopt failed on '/data/dalvik-cache/data@MY_APP.apk@classes.dex' res = 11

any ideas?
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
Grabbed your deodexed files and messed around for a couple of hours, but got no where apart from replicating the same problems.

Get this in logcat just prior to app fails to install with secmediarecorder

Invalid file flags in class Lcom/sec/android/secmediarecorder/SecMediaRecorder$EventHandler;: 0002

are we maybe missing some other dependencies?
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I've managed to get SecCamera working (not tried SecMediaRecorder yet)

I grabbed the .jar & .odex from the phone (/system/framework)

Deodexed the files (smali/backsmali)

Built the class files (dex2jar)

Converted to source (jd-gui)

Created a new java project

Pasted in the java source

Fixed a ton of errors??? (just deleted most of them)

Exported the jar

Added the new jar into my project build path

I can now reference the samsung camera object, compile, install and run my project.

I've attached the single new jar here (SecCamera), and I'll try sort the other one tomorrow when I have a bit more free time...
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
Here are both the new files, seccamera.jar & secmediarecorder.jar

Add these as external jars to your build path, any it will allow you to work around the firmware bug and also to utilise some extra Samsung goodies for the SG2.
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
Good job!

But if it runs on non Samsung phones what will be? Force close?

My lgCamera user java.lang.Reflection to access Sec-classes. And if phone is not Samsung it work with android.media.MediaRecorder and android.hardware.Camera.

BTW, new version of lgCamera(available in Android market) supports pause/resume for Samsung phones
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
Yes, it will cause an FC, but you could also check the phone model first, or catch the error on the initial attempt to use the class.

try {
Class.forName( "com.sec.android.seccamera" );
} catch( ClassNotFoundException e ) {
//class isn't there!
}
[Galaxy S II Q&A, Help & Troubleshooting] TrallaP:
Nifty stuff, thanks for all the work. :)
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
Keep your work!

And you will beat me.

But for right camera recording you need some Camera parameters set.

Or Camera does not keep exposition or focus mode.
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I'm getting an error when trying to set the video/audio source in the SecMediaRecorder object

The last two lines give errors

mSecCamera.stopPreview();
mSecCamera.unlock();
mSecMediaRecorder = new SecMediaRecorder();
mSecMediaRecorder.setCamera(mSecCamera);
mSecMediaRecorder.setAudioSource(SecMediaRecorder.AudioSource.CAMCORDER);
mSecMediaRecorder.setVideoSource(SecMediaRecorder.VideoSource.CAMERA);

give these errors

VERBOSE/SecMediaRecorderJNI(11650): setAudioSource(5)
WARN/(2582): PVAuthorEngine::SetPVAEState: aState=1
ERROR/audio_input(2582): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
ERROR/audio_input(2582): VerifyAndSetParameter failed
VERBOSE/SecMediaRecorderJNI(11650): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(11650): setVideoSource(1)
ERROR/CameraInput(2582): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
ERROR/CameraInput(2582): VerifiyAndSetParameter failed on parameter #0

Scratching my head... any ideas?
[Galaxy S II Q&A, Help & Troubleshooting] musify:
I had the same problem on SGS2, but after changing to custom resolution under settings, I can select h263 as encoder and it plays back perfectly at all resolutions.
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
DailyRoads Voyager can not record higher than 800x480.

Even H.263 encoder set, it alway record in 800x480 resolution.

But my lgCamera and my VideoReg can record up to 1920x1080 (on SGS2) and 1920x1088(on nVidia Tegra2 devices).

UKLooney

Please show to me all your code.
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
Thanks Pm'd :)
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
I think there is error:

mCamera.stopPreview();

// unlock the camera

mCamera.unlock();

What for you turn camera preview off? Try to remove this line (or comment)
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
Looked promising, but removal had not effect :(

With or without this line, the standard MediaRecorder works fine, but you're right, it shouldn't be there.

I've made a stripped down, minimal app. It might help to debug. It works OK with the original code, but same error using the Samsung classes when setting the video and audio sources.

Here's it is in pastebin

http://pastebin.com/6JSrGgg0

Same errors, I might be missing a parameter or two??

VERBOSE/SecMediaRecorderJNI(11650): setAudioSource(5)
WARN/(2582): PVAuthorEngine::SetPVAEState: aState=1
ERROR/audio_input(2582): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
ERROR/audio_input(2582): VerifyAndSetParameter failed
VERBOSE/SecMediaRecorderJNI(11650): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(11650): setVideoSource(1)
ERROR/CameraInput(2582): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
ERROR/CameraInput(2582): VerifiyAndSetParameter failed on parameter #0

Thanks much...
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
May be there are errors in SecCamera, SecMediaRecorder classes
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
Aren't the classes in the jar's on the phone?
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
UKLooney

What classes do you use? From phone or your maded?

I use Sec-classes via java.lang.Reflection from phone in my app lgCamera and this classes work perfect. But using java.lang.Reflection is very difficult and it not for beginner programmer
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I rebuilt the classes using the jar files found on the phone (posted above). I added them to my project's build path as external jar's, which allows me to see & reference the samsung classes in my project. I was assuming that the external classes/jar's are not included when the app is built, and that the compiled app will use the classes on the phone.

I'm guessing now this is wrong??
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I crudely rewrote the example above, but using java.lang.Reflection.

Sadly, I get the exact same results :mad:

Again, it works OK when I target the Camera/MediaRecoder classes instead of SecCamera/SecMediaRecoder.

Crude rewrite in pastebin --> http://pastebin.com/aXm6tAy5

I still get the same logcat error messages when setting the video and audio sources. I have since examined the logcat when using your app , lgCamera, the same errors are produced, so it seem the problem isn't directly related...

Here is an extract from the logcat from when the mediarecorder is being setup.

ERROR/TestCamcorder(7139): ERROR BEING REPORTED HERE
VERBOSE/SecMediaRecorderJNI(7139): setVideoSource(1)
WARN/(2582): PVAuthorEngine::SetPVAEState: aState=1
ERROR/CameraInput(2582): Unsupported parameter(x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value)
ERROR/CameraInput(2582): VerifiyAndSetParameter failed on parameter #0
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
ERROR/TestCamcorder(7139): SET AUDIO SOURCE
VERBOSE/SecMediaRecorderJNI(7139): setAudioSource(1)
ERROR/audio_input(2582): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
ERROR/audio_input(2582): VerifyAndSetParameter failed
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
ERROR/TestCamcorder(7139): SET PROFILE
VERBOSE/SecMediaRecorderJNI(7139): setOutputFormat(1)
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setVideoFrameRate(30)
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setVideoSize(176, 144)
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setParameter()
DEBUG/AuthorDriver(2582): setParamVideoEncodingBitrate() 256000
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setParameter()
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setParameter()
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setParameter()
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setVideoEncoder(2)
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
VERBOSE/SecMediaRecorderJNI(7139): setAudioEncoder(1)
VERBOSE/SecMediaRecorderJNI(7139): process_sec_media_recorder_call
ERROR/TestCamcorder(7139): SET PREVIEW DISPLAY
ERROR/TestCamcorder(7139): SETOUTPUTFILE
ERROR/TestCamcorder(7139): PREPARING
ERROR/TestCamcorder(7139): STARTING
VERBOSE/SecMediaRecorderJNI(7139): start
ERROR/MediaRecorder(7139): start called in an invalid state: 4

Somehow the MediaRecorder is not prepared correctly????
[Galaxy S II Q&A, Help & Troubleshooting] danim:
Just a guess - did you remove the homemade SecCamera/SecMediaRecoder as external jars? If not, perhaps removing them will allow using the ones on the phone.
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
You might be right, I'll take a look in the morning...
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I removed the jars from the build path and found that I had to explicitly load the external classes. Now, I got video recording working using the samsung classes. :)

The problem now, is that video recorded @ 1080p is STILL exhibiting the exact same corruption (multiple images & green atrifacts). :eek: :confused:
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I've tidied up the source for my test app, should be a bit more readable now...

---> http://pastebin.com/eeNH06Tp
[Galaxy S II Q&A, Help & Troubleshooting] danim:
Damn, back to square one :(

1. Check out this link on how to access hidden and internal APIs, it may help get rid of the reflection, though it will probably not help with the core issue here:

https://devmaze.wordpress.com/2011/01/18/using-com-android-internal-part-1-introduction/

2. I find it a bit odd that there are close to 0 references on Google to SecMediaRecoder, other than links to this thread. I also don't understand why the normal API's don't work - even if the implementation is different, it's expected Samsung would map the standard APIs to the correct implementation.

Does anyone know how we can contact Samsung on such a technical issue? I suspect customer service will not understand a word... Inability to use standard APIs is a critical bug that Samsung must address, it's not like we're trying to do something that isn't supported.
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
RubberBigPepper has got it working using Reflection in his app lgCamera, so there are a few more things to try before I give up.

The alternative method you posted seems to be similar to the first approach I took, by rebuilding the jars from source and including them with the app. These files are owned by samsung though, and the ones posted earlier seem to have errors too (I was a bit slapdash when I was rebuilding them).

I think I'm just missing some camera or mediarecorder parameter settings specific to the samsung classes that are not needed by the standard classes. :confused:

Gonna go stare at the code for another hour or so now...
[Galaxy S II Q&A, Help & Troubleshooting] pmhwong:
I got as far as you have. Used reflection to access SecMediaRecorder and got the same results as without using it.

Would you be able to find anything useful by reverse engineering the lgCamera?
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
May be should ask before reversing?
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
LOL, that was probably going to be my next post.

I've been looking through the reversed SG2 camera app source again, but my head just hurts more now. Any ideas where I'm going wrong, or what I'm missing?

I've since tried setting up the media recorder parameters individually, instead of using the HQ CamcorderProfile, but no joy. Tried setting some other camera parameter too.

I also can't figure out how to implement the samsung autofocus callback and others, with reflection in my code, and I can't find much about it searching the interweb? Can anyone point me to some good reading? My java skills suck :)
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
Sec-classes is not needed for fullHD recording on SGS2

But if you want pausing when recording, than those classes is required.

For fullHD recording you need only set right camera parameters, not a recorder.

Thats all

PS. lgCamera is fully reflected now. It use Sec-classes for samsung phones (with pausing feature) and standard MediaRecorder and Camera classes for other phones.

Callbacks functions uses Proxy intsance class.
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
What are the right parameters?
[Galaxy S II Q&A, Help & Troubleshooting] pmhwong:
Need to make the preview size 1920x1080 or 1280x720 without it complaining that it is not supported.
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
how can i do that?

i noticed that whenever i try to set it to HD res, it shows this in ddms:

09-03 01:33:20.285: WARN/ISecCameraHardware(2588): setPreviewSize: warning, not supported size(1920x1080)

09-03 01:33:20.285: DEBUG/ISecCameraHardware(2588): setPreviewSize: preview 640x480

09-03 01:33:20.285: WARN/ISecCameraHardware(2588): setPreviewFormat: warning, not supported value(17)

but stock cam shows this (no WARN msg):

09-03 01:31:36.295: DEBUG/ISecCameraHardware(2588): setPreviewSize: preview 1920x1080

is there some other parameter name that can set HD preview size?
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I've had no success here...
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
Quite RIGHT step! Go on! The solution is very close.
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
close? but yet so far away!! without further clues, there are only an infinite number of possibilities that i can try. for all i know, it could be i need to set the preview size using korean words!
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I've looked through the de-compiled SecCamera class source, and nothing happens out of the ordinary. SecCamera.setParameters just invokes native_setParameters
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
you looked at SecCamera? see anything wrong with this method in SecCamera?

public void setPreviewSize(int paramInt1, int paramInt2)

{

StringBuilder localStringBuilder1 = new StringBuilder();

String str1 = Integer.toString(paramInt1);

StringBuilder localStringBuilder2 = localStringBuilder1.append(str1).append("x");

String str2 = Integer.toString(paramInt2);

String str3 = str2;

set("preview-size", str3);

}
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
Yeah, that looks way messed up, but I've been looking here...

.method public setPreviewSize(II)V
.registers 6
.parameter "width"
.parameter "height"

.prologue
.line 2091
new-instance v1, Ljava/lang/StringBuilder;

invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

invoke-static {p1}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;

move-result-object v2

invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v1

const-string v2, "x"

invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v1

invoke-static {p2}, Ljava/lang/Integer;->toString(I)Ljava/lang/String;

move-result-object v2

invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

move-result-object v1

invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

move-result-object v0

.line 2092
.local v0, v:Ljava/lang/String;
const-string v1, "preview-size"

invoke-virtual {p0, v1, v0}, Lcom/sec/android/seccamera/SecCamera$Parameters;->set(Ljava/lang/String;Ljava/lang/String;)V

.line 2093
return-void
.end method

I've also tried side stepping SetPreviewSize completely and using Set("preview-size", "1920x1080");

Still then same though...

Invoking the setPreviewSize seems to be work fine for me? The error is being thrown when the SetParameters method in invoked in the Camera Object.
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
You are going around the point...

Try this code:

Camera.Parameters cParams=m_cCamera.getParameters(); //or use SecCamera-

cParams.set("cam_mode",1);//abracadabra!

m_cCamera.setParameters(cParams);

m_cCamera.setPreviewSize(1920,1080);
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
that's fricking awesome! thanks so much!! finally i can get some sleep at night!!
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
now all i need to do is get this auto exposure to work.
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
i don't think it's auto-exposure i want. i noticed that during recording, the brightness doesn't auto-adjust. It is fixed at the brightness it adjusted to at the start of recording. anyone know what setting is that to make it auto adjust the brightness?
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I thought magicians didn't divulge their secrets?

Cheers, I can sleep now also.
[Galaxy S II Q&A, Help & Troubleshooting] RubberBigPepper:
Only for big money, big other people money.

There are some magic words for autoexposure and focusing when recording
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
damn. i was screwing around with the camera parameters trying to get the auto exposure to work, but somehow the "cam_mode"=1 no longer works anymore! i tried undoing everything i did, and even restarting the phone... but for the life of me i can't get it to record HD anymore! any ideas?!
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
a logcat dump might help
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
parameters.set("focus-mode", "continuous-video"); ???

parameters.set("iso", "movie"); ???
[Galaxy S II Q&A, Help & Troubleshooting] 12am:
nevermind my previous problem. by fluke I broke it, and by fluke it righted itself again. i don't know what it was.

thanks for the the tips. it works.
[Galaxy S II Q&A, Help & Troubleshooting] aerobahn:
:(

I've gotten HD recording to work but I still have a huge problem. I tried these parameters and the 720p (and 1080p) video still doesn't autofocus or autoexposure. Can anyone tell me if there are other parameters to pass that would allow recording of HD video with autoexposure & autofocus? I'm trying to make a simple vid. recording app as practice but Samsungs proprietary SEC is messing things up :mad:

I've made a short youtube video showing my no-autoexposure & no-autofocus problem. Please help :o

http://www.youtube.com/watch?v=wzBD0fo-NV0
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
this is all you should need
[Galaxy S II Q&A, Help & Troubleshooting] Alex.V.T:
cam_mode=1 causes another problem

Hi,

On my SGS2, setting "cam_mode=1" fixes the HD video problem but causes another one: MediaRecorder.start() takes approx. 8 sec to start recording. During this delay, the application is just freezing.

The issue exist in both UKLooney's aLapRecorderHD and my quick and dirty video recording sample.

I'd been playing with everything I could only imagine but surely, it's cam_mode=1 that triggers such weird behaviour.

The problem is also mentioned here although in another context.
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
I do not see this problem on my device

2.3.3, XWKE2
[Galaxy S II Q&A, Help & Troubleshooting] Alex.V.T:
Mine is 2.3.3, I9100XXKE7, GINGERBEARD.XWKF3
[Galaxy S II Q&A, Help & Troubleshooting] Alex.V.T:
Just got my phone updated to 2.3.5 I9100XXKI4 GINGERBEARD.XWKI8. The problem is still there. I've been trying using both Camera+MediaRecorder and SecCamera+SecMediaRecorder with no difference. It seems that system apps only can record HD video on my phone...
[Galaxy S II Q&A, Help & Troubleshooting] PtSy:
First, thanks for the "cam_mode" hint. It works fine with two problems:

1) There is a false-color part in the live-preview viewfinder on the bottom.

2) The video is automatically recorded with (max?) zoom.

Anyone experiencing the same?
[Galaxy S II Q&A, Help & Troubleshooting] vladimir.shakula:
please, everyone, plese give some source how write hd video?

any source or sample when is recording hd video on SII! Please...
[Galaxy S II Q&A, Help & Troubleshooting] Alex.V.T:
Yeah, you're right ;) The standard workflow (http ://developer.android.com/guide/topics/media/camera.html#capture-video) works pretty well. The trick is in the camera initialization. After instantiating your Camera object, do the following:

mParameters = mCamera.getParameters();
if ( mParameters == null ) {
Log.e(TAG, "Error reading camera parameters");
return;
}

// green mess in video file without this
mParameters.set( "cam_mode", 1 );

// must be set to the VIDEO size, not the preview size,
// or the video won't be recorded.
mParameters.setPreviewSize(mProfile.videoFrameWidth, mProfile.videoFrameHeight);

// Without this, MediaRecorder.start() sleeps for approx 8.5 sec on my SGS2 before
// start recording; some other SGS2 may not be affected
mParameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);	// works
//mParameters.setFocusMode(Parameters.FOCUS_MODE_INFINITY);	// works as well

mCamera.setParameters(mParameters);	// catch RuntimeException

// Use it AFTER setParameters();
// Angles:
//	0 for landscape, the home button on the right
//	90 for normal portrait
//	180 weird results, not tested well
//	270 weird results, not tested well
mCamera.setDisplayOrientation(0);

I've attached the quick and dirty but working sample code.

Hope this helps.

P.S. Many thanks to RubberBigPepper and UKLooney for the clues!
[Galaxy S II Q&A, Help & Troubleshooting] PtSy:
And it's important to set the viewfinder size to the video dimension size (e.g. 1920x1080). Else you will get a distorted video (green and red-ish blocks).
[Galaxy S II Q&A, Help & Troubleshooting] UKLooney:
setting dimension to 1920x1080 allows the camera to allocate a properly size memory space for the camera data to be buffered into. When the incorrect buffer is later read and compressed, most of it has been lost.

I've found that setting the angle to 180, sets a parameter in the video file header to indicate to the playback software that the video should be inverted when played back. This is because the video is still encoded upside down. Sadly, some older players/encoders do not interpret this flag and the video plays the wrong way up.

The example code looks good to me :)