Extracting metadata using windows media format 11 sdk - wmf

I've never used the windows media format 11 sdk before and I'm just trying to understand the documentation behind text. I don't understand the line where it says, "In order to use the function, you must pass it a pointer to the IWMHeaderInfo3 interface of a metadata editor object, reader object, synchronous reader object, or writer object". Where do these objects come from? And how do I get them from a video file path?
I wish there was some function like printAllAttributes(std::string videoFilePath) or something.

Related

Send an image from smart device to the server in Genexus

I know there is already a similar question but the answers to that didn't work for me
I'm working with Genexus 16U11 and I have a panel with an image variable (called &sourceImage) with control type as "SD Image Annotation". I need to send this image to the server, in a specific folder. According the documentation if I call a procedure using the image as variable this should go on the server but it's not working. I can't find the image anywhere, I searched also in the PublicTempStorage directory, in the procedure is as the variable is empty.
I tried also to convert the image in base64 to send it as longvarchar to the procedure
&blob = &sourceImage.GetAnnotatedImage()
&longvarchar = ToBase64(&blob)
but in this way I can only get this string ZmlsZTovLy8vc3RvcmFnZS9lbXVsYXRlZC8wL0FuZHJvaWQvZGF0YS9jb20uYXJ0ZWNoLnJpY2hpZXN0YXBlcm1lc3NpMTZ1MTEuc2Zpcm1hL2ZpbGVzL3RyYW5zZm9ybWF0aW9ucy8yMDIyLTAzLTE4LS0xNC00My0yNi02MTQ2NDcyMTA5MjM5NDU3NzgzODAxLnBuZw==
that is the path of the file
file:////storage/emulated/0/Android/data/com.artech.richiestapermessi16u11.sfirma/files/transformations/2022-03-18--14-43-26-6146472109239457783801.png
I tried with file variable, blob, image, extra images, method fromUrl, nothing is working.
What am I doing wrong?
To upload the image to the server you need to call the procedure in the server (Connectivity=Online).
Then the image variable will be send to the server and you can save, copy, etc. there.
For example, save in a Transaction with a code like this:
Call in the panel:
Composite
&resultImage = &ImageA.GetAnnotatedImage()
procSaveImage(&resultImage)
EndComposite
Procedure online:
&TrnData = new()
&TrnData.TrnDataImage = &parmImage
&TrnData.Insert()
if &TrnData.Success()
commit
Working in Genexus v17u8 .

What is the "=>" operator?

In this link from MDN, it explains how to write a unit test for developing an addon for firefox. However, there are several segments that I don't understand and didn't find any useful result after searching google.
The first one, the following is a paragraph quoted from above link:
In a web page, you can perform Base64 encoding and decoding using the
btoa() and atob() functions. Unfortunately these functions are
attached to the window object: since this object is not available in
your main add-on code, atob() and btoa() aren't available either. So
we'll create a base64 module to expose these functions from the
platform (see Creating Reusable Modules).
What does "the platform" in the above paragraph mean? the "Services.jsm"?
Also in the following code:
const { atob, btoa } = require("resource://gre/modules/Services.jsm");
this makes atob and btoa as one of the Services that is available for other class? or make (constant variables)atob and btoa both reference to the Services.jsm?
The Second one:
what are these two lines of code do?
exports.atob = a => atob(a);
exports.btoa = b => btoa(b);
I understand the part
exports.atob
which enables atob function to be available from other classes outside the "base64.js".
but what does the following mean?
= a => atob(a);
I didn't find that javascript has "=>" operator!
From my understaning, the reason we create a base64.js is because atob and btoa can only be called if we have the window object. Therefore we can use Services.jsm to get a reference of the window object?
For "platform" in the paragraph you quoted they mean the set of functions which is not strictly Firefox browser code but rather implements basic, share functionalities. This usually lives in toolkit/modules in the mozilla-central repository. Services.jsm lives there as well so yes, that's part of the platform. Moreover, atob and btoa are both imported from Services.jsm.
The arrow => in exports.atob = a => atob(a); defines what's called an arrow function: it's a new, shorter syntax to define functions in JavaScript. This SO answer has many useful informations about it.
From my understanding, the reason we create a base64.js is because atob and btoa can only be called if we have the window object. Therefore we can use Services.jsm to get a reference of the window object?
That's almost correct: you need to export the function from the underlying platform as you don't have a window object there. If you had a window object, you would have just done window.atob or something like that. That call would have still called the same function you imported from Services.jsm.
So you're not using Services.jsm to get a reference to the window object, but rather directly importing the needed functions so that you don't need to have a window object.

Is there any way to recreate an object from the output of its Object.inspect method?

While working with the open source ELK stack, we have run into an issue where one of the Logstash inputs snmptrap is formatting data in a way that is unusable for us. Within the SNMPv1_Trap class there is an instance variable called agent_address which is stored as a SNMP::IpAddress. For anyone familiar with the way SNMP works, the agent address is extremely important in determining where a SNMP trap originated from when using trap relays on your network.
The problem can be seen when you take a look at an event generated by Logstash upon receiving a trap. Mainly, the inspect method of the agent_address variable is dumping data that does not match anything valid.
A sample event looks kind of like this:
#<SNMP::SNMPv1_Trap:0x2db53346 #enterprise=[1.3.6.1.4.1.6827.10.17.3.1.1.1], #timestamp=#<SNMP::TimeTicks:0x2a643dd1 #value=0>, #varbind_list=[#<SNMP::VarBind:0x2d5043a5 #name=[1.0], #value=#<SNMP::Integer:0x29fb6a4a #value=1>>], #specific_trap=1000, #source_ip=\"192.168.87.228\", #agent_addr=#<SNMP::IpAddress:0x227a4011 #value=\"\\xC0\\xA8V\\xFE\">, #generic_trap=6>
We know however, that the IpAddress object used in SNMP::SNMPv1_Trap is able to return us a nicely formatted string representing the IPv4 address it is storing.
For example:
require 'snmp'
include SNMP
address = IpAddress.new(192.168.86.254)
puts address
will yield 192.168.86.254 whereas:
require 'snmp'
include SNMP
address = IpAddress.new(192.168.86.254)
puts address.inspect
will yield:
#<SNMP::IpAddress:0x0000000168ae88 #value="\xC0\xA8V\xFE">
This is the expected behaviour of an object whose .inspect method has not been overridden.
Obviously the IPv4 address in #value is not useful to us, it has only three valid hex sequences (xC0=192, xA8=168, xFE=254) and also contains an invalid hex sequence ('V'). The same thing occurs whenever an octet string representing an IPv4 address is sent as a variable binding as well, which suggests some strange encoding.
Unfortunately, aside from writing our own SNMP input, there is no interface level access to this object. The object we receive via 'event' contains the inspect string, not the object itself. Therefore, the easiest apparent way to get the information we need would be to reconstruct the SNMPv1_Trap object and then make our own calls to it via Object.#send.
If I have the raw, unformatted and default string dump returned by Object.#inspect, is there any way to physically recreate the object used to make this inspect dump on the fly?
For example, given the string dump:
#<Integer:0x2737476 #value=1>
is it possible to recreate an Integer object with a field whose value is 1?. If this is possible, is there also a way to recreate nested objects the same way? For example, given the string:
#<SNMP::SNMPv1_Trap:0x2ef73621 #value=1, #agent_address=#<SNMP::IpAddress:0x0000000168ae88 #value="\xC0\xA8V\xFE">>
Would it possible to have an object that looks like the following?
SNMP::SNMPv1_Trap{
#value : 1
#agent_address : SNMP::IpAddress{
#value : 1
}
}
If I have the raw, unformatted and default string dump returned by Object#inspect, is there any way to physically recreate the object used to make this inspect dump on the fly?
No. inspect is intended for debugging purposes to be read by humans.
It is not guaranteed to be machine-readable. It is not guaranteed to be the same across different Ruby versions. It is not guaranteed to be the same across different Ruby implementations. It isn't even guaranteed to be the same across different versions of the same Ruby implementation implementing the same Ruby version. Heck, I don't even think it is guaranteed to be the same across two runs!
It is not a serialization format.
There are plenty of serialization formats specifically for Ruby (Marshal) or generically (XML, YAML, JSON, and of course ASN.1), but inspect isn't it.

Change h.264 quality when using SinkWriter to encode video

I am using Microsoft Media Foundation to encode a H.264 video file.
I am using the SinkWriter to create the video file. The input is a buffer (MFVideoFormat_RGB32) where I draw the frames and the output is a MFVideoFormat_H264.
The encoding works and it creates a video file with my frames in it. But I want to set the quality for that video file. More specifically, I want to set the CODECAPI_AVEncCommonQuality property on the H.264 encoder.
In order to get a handle to the H.264 encoder, I call GetServiceForStream on the SinkWriter. Then I set the CODECAPI_AVEncCommonQuality property.
The problem is that my property change is ignored. As stated in the documentation:
To set this parameter in Windows 7, set the property before calling IMFTransform::SetOutputType. The encoder ignores changes after the output type is set.
The problem is that I don't create the H.264 encoder manually. I set the input and the output type on the SinkWriter, and the SinkWriter creates the H.264 encoder automatically. As soon as it creates the encoder, it calls the IMFTransform::SetOutputType method, and I can't change the CODECAPI_AVEncCommonQuality property anymore. The documentation also says that the property change isn't ignored in Windows 8, but I need this to run on Windows 7.
Do you know how I can change the quality for the encoded file while using SinkWriter on Windows 7?
PS: Someone asked the same question on the msdn forums, and he didn't seem to get an answer.
As the documentation says, you just can't change the CODECAPI_AVEncCommonQuality property after the output type is set, and the SinkWriter sets the output type before you can get a hand on the encoder.
In order to bypass this problem I managed to create a class factory and register it in Media Foundation, so that the SinkWriter uses it to create a new encoder. In my class factory, I create a new H264 encoder and set whatever properties I want before passing it on to the SinkWriter.
I have written in more detail the steps I took to create this class factory on the MSDN forums, here: http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/6da521e9-7bb3-4b79-a2b6-b31509224638
That was the only way I could get around my problem on Windows 7.
CODECAPI_AVEncCommonRateControlMode and CODECAPI_AVEncCommonQuality can be passed to the h.264 encoder using IMFSinkWriter->SetInputMediaType(/* ... */,, IMFAttributes pEncodingParameters). I suspect other CODECAPI_ values would work as well.
CComPtr<IMFAttributes> pEncAttrs;
ATLENSURE_SUCCEEDED(MFCreateAttributes(&pEncAttrs, 1));
ATLENSURE_SUCCEEDED(pEncAttrs->SetUINT32(CODECAPI_AVEncCommonRateControlMode, eAVEncCommonRateControlMode_Quality));
ATLENSURE_SUCCEEDED(pEncAttrs->SetUINT32(CODECAPI_AVEncCommonQuality, 40));
ATLENSURE_SUCCEEDED(writer->SetInputMediaType(sink_stream, mtSource, pEncAttrs));
// ^^^^^^^^^

Burning CD/DVD using IMAPI2.dll

I am trying to add the facility to burn CD/DVD into my app by using IMAPI2.dll. I am using Microsoft Visual FoxPro 9 SP 2 to devolopment. When I invork the method Write() which is a member of the IMAPI2.MsftDiscFormat2Data class (Last line of the sample code) Visual FoxPro gives the following error message. Error Msg : "OLE error code 0x80004002: No such interface supported."
OS : Windows 7
Please Help.
**--Creating MsftDiscMaster2 object to connect to optical drives.
loDiscMaster = CREATEOBJECT("IMAPI2.MsftDiscMaster2")
**--Creating MsftDiscRecorder2 object for the specified burning device.
loRecorder = CREATEOBJECT("IMAPI2.MsftDiscRecorder2")
lcUniqueId = loDiscMaster.ITEM(0)
loRecorder.InitializeDiscRecorder(lcUniqueId)
**--Create an image stream for the specified directory.
loFileSystem = CREATEOBJECT("IMAPI2FS.MsftFileSystemImage")
loRootDir = loFileSystem.Root
**--Create the new disc format and set the recorder.
loDataWriter = CREATEOBJECT("IMAPI2.MsftDiscFormat2Data")
loDataWriter.Recorder = loRecorder
loDataWriter.ClientName = "IMAPIv2 TEST"
loFileSystem.ChooseImageDefaults(loRecorder)
**--Add the directory and its contents to the file system.
loRootDir.AddTree("F:\VSS",.F.)
**--Create an image from the file system
loResultImage = loFileSystem.CreateResultImage()
loStream = loResultImage.ImageStream
**--Write stream to disc using the specified recorder.
loDataWriter.Write(loStream)
I'm afraid you are out of luck there. FoxPro interacts with COM objects at a fairly high level. In fact, it works in much the same way that VBScript interacts with COM. Normally, if your code works in VBScript, it will also work in FoxPro.
This is actually a common problem with some ActiveX/COM libraries. While the objects implemented in imapi2.dll and imapi2fs.dll all use IDispatch - the highest level and most interoperable form of COM interface - some of the method parameters, method returns, and properties of those objects are not IDispatch.
Specifically, the ImageStream property returns something called an IStream which inherits from IUnknown instead of IDispatch. Because of this, the ImageStream property returns something that FoxPro doesn't know how to deal with. FoxPro knows that it is a COM interface, but it doesn't know how to find or call the methods on that object.

Resources