Friday 29 July 2016

What is the output of below C program? If it gives error Please correct code.

#include <stdio.h>

main()
{
        int *p = NULL;

        *p = 2;

        printf("Value of *p %d\n", *p);

        return 0;
}

Thursday 28 July 2016

5 SIGNS THAT YOU NEED A JOB CHANGE


Your job is under scrutiny

If your job role is being questioned, or your division is being merged with another unit, sold off to other company or your work is being outsourced then you should certainly update your CV and actively look for a job.

 

 

 

There's nothing new to learn

There can be a time in your career when you feel there is nothing more for you to learn in the present role and company. It's time to head to a new adventure.

 

 

 

 

Corporate politics is killing you

Office is not just about work but about a decent culture too. But if you have become a target of unnecessary arguments or blame game from the team then you need a break from this job.

 

 

 

 

You hate your boss

The relationship between a boss and his subordinate can hit a rough patch any time but if it aggravates to a level that it becomes a personal issue for both, then it's better to walk out such an arrangement.

 

 

 

Company is in chaos

If your present company is in limbo and has an uncertain future, then it's safe to walk out of it as soon as possible and cash on its reputation and name till it lasts.



SourceLink.

What is Point of Sale (POS)?



POS alias Point of Sale is a place where transactions take place. You can see POS systems in Retail Stores, Restaurants, Hospitals and almost everywhere these days where payments are involved.
Most of you may very well understand what a barcode reader is or a wireless payment device is (the most used devices for payment transactions) but POS, in reality, involves a lot of components and each of the components needs to be integrated well for it to run successfully. 
In today’s article, I am going to write about what makes POS testing different from others. I have also incorporated testing tips throughout the article to make this helpful for our testing community.

Facts About Airplanes That’ll Make You Think Twice About Flying


1. Takeoff is a very dangerous time.
The fear of flying stems from the thought of the plane going down. Bu t the fact is that you are equally unsafe on the ground. Heavy fog and botched up radio signals have resulted in the worst airplane disasters. Mayday, mayday!
2. It's a germ overload.
Agreed, airports and planes look spic-and-span, but the planes may not be as clean from the inside as you assume them to be. With more people than ever queuing up to fly, the in-flight staff might not really have the time to do a thorough cleansing of the cabin. Seats, safety belts, buttons... the germs are everywhere and are waiting to wriggle all over you. Gross!
3. The pilot is often exhausted.
According to a study, more than half of the pilots have fallen asleep in the cockpit. This is due to their extensive working hours and the toll the time zones take on them. I don't even want to know what happens when both the pilot and the co-pilot are fast asleep at the controls.
4. You might be flying in a plane with the engine down.
Planes are designed to travel extensive periods of time on one engine. Well, pilots know exactly what information to give you and they'll never tell you anything that's bound to cause panic. You'll know that something went horribly wrong only when you're about to crash into a mountain.
5. The black box can be destroyed. Contrary to popular belief, the small box is destructible if it comes under the heavy wings of the plane or is exposed to the extreme heat of the plane's fuel. There's still a slim chance that it would emerge intact. You'd be dead anyway!



6. There's more risk of turbulence now than ever before.
Thanks to global warming, there's an increase of carbon dioxide in the air. So the next time you keep your ignition burning for too long at the red light, remember you are contributing that much more to global warming. Which in turn is causing turbulence for someone up in the sky.
7. Pilots don't eat airline food.
Pilots are served special food on the plane while you are busy wondering why the toast is hard as rock. Reason? Airlines don't want pilots to fall sick! Does that mean...? Dayum!

 
8. Oxygen masks won't last for more than 15 minutes.
This is scary. Airlines claim that in 15 minutes, the pilot will bring the plane down to an altitude where you can breathe normally. They don't tell you all that because they don't want you to start shitting bricks.
9. Those earphones were plugged into somebody else's ears.
Yuck! Sure, someone cleans the earphones and neatly tucks them back into the plastic cover but I wonder how much effort would someone put into cleaning earphones that are not supposed to go into his own ears.
10. The planes are not as new as you think.
According to 'Airfare Watchdog', an airline expert, the skies are full of old airplanes including the Boeing 717s and the primitive versions of the 757, 767 and 737. Before the production of 757 was brought to a halt, you could have been flying in the same plane that your grandfather flew in 20 years ago. Sounds a lil scary, eh?

4 Software Quality Lessons from Pokemon Go’s Wild First Week

      Pokemon is near and dear, not just to the hearts of 90s kids, but pretty much everyone who ever played video games. Pokemon Go triggered the nostalgia and took smartphone gaming to the next level.
In fact, Pokemon Go is already the biggest US mobile game of all time, with 21 million active users.
Pretty much everything that could be said about the game has already been said — from how it’s just the beginning of augmented reality gaming on mobile, to how its putting lives in danger and need to be stopped. Some even went ahead and debated the ethics of Pokemon Go, and whether or not we want games to have access to user data or own the virtual space around your home.
But what made the most news about Pokemon Go is the issues people faced with it. I myself couldn’t login using my Google credentials because it ‘Failed to connect to the server.’ When I could eventually login, I couldn’t catch a Bulbasaur sitting two feet away from me because it ‘lost GPS connection’. There are a number of posts already available listing down all Pokemon Go problems and suggesting possible solutions. Google Play and iTunes are flooding with apps that try to ‘fix’ Pokemon Go problem and keep your hunt ongoing.

But this doesn’t stop us from asking a simple question: why so many problems?

Were the game creators not ready for such overwhelming response? Or did they not test all possible use cases — including geolocations, devices, operating systems, hardware, diverse transaction etc. — before launching?
Almost every day of its first week, the Pokemon Go servers have crashed and people have reported numerous other problems with user experience. Thankfully nothing has affected the virality of the game as of now. Niantic, the company behind the game is already learning a lot from every hurdle and has fixed multiple issues already. However, considering that it just launched in a few countries for now, and is set to go worldwide soon, the game makers are in for even bigger and unforeseen challenges.
We are all about software quality at SmartBear. So we decided to list down our suggestions to the game creators and someone who’s trying to learn from Pokemon Go’s obstacles and develop the next viral game!

Lesson #1: You are as strong as your weakest link(s) — testing and monitoring the APIs

Pokemon Go is all about APIs. Right from logging into the app to identifying locations, seeing augmented reality, collecting pokemon, battling in PokeGym or just walking; everything is fueled by APIs that transfer data and requests. Some of those APIs are internally developed by Niantic and some of them are popular public APIs such as Google geolocation APIs.
The CEO and founder of Niantic, John Hanke, is an ex-Googler who worked on Google Earth and Google Maps initial design and development. So let’s say he knows a thing or two about geolocation mapping and it’s potential.
Many players faced problems where the game couldn’t detect GPS location, or in some cases detected wrong locations.
There are multiple problems here:
  • the availability of the API endpoint
  • the speed at which it responds to the request
  • the functional correctness of the payload
Since the whole game is based on geolocation correctness and preciseness, even a slightest error in the API payload can dilute the user experience. Hence, the game makers not only need to test the API functionality from all different angles before deployment, but also need to monitor the API for functional correctness from all diverse user scenarios – geographies, devices, operating systems and service providers.

Lesson #2: Validate user-generated data

Pokemon Go isn’t Niantic’s first rodeo in the augmented reality arena. In early 2011, they had launched a beta version of Ingress, another multiplayer augmented reality game, which let users pick landmarks and historical locations as ‘portal locations’. Ingress gave Niantic a database of over 15 million portal locations which were used in Pokemon Go for gyms and Pokestops. Thousands of Ingress users made sure that you can play Pokemon Go at almost any remote place. In Pokemon Go, users can submit Pokestops.
Crowd-sourced data is phenomenal when it comes to building an augmented reality game, however the data is still user generated and is naturally susceptible to human errors. This post about Pokestops in the strangest places will give you a mere hint of the problem. Unnecessary traffic in some of these locations can raise security and public health and safety concerns. Who should have control over this? Of course the game makers!
This is just one example of user-generated data and its implications, but we all agree that there should be some kind of validation and testing done on user-generated data.

Lesson #3: Test and monitor the front end

Pokémon shows the increasing dependency of mobile apps on back-end APIs. In this case, the APIs and GUI are interdependent on each other to collect information. Hence, testing apps both at the API and GUI layer becomes important.
The front-end graphical user interface (GUI) of Pokémon depends not only on the API responses, but also on mobile device hardware/sensor data. For instance, in this case, the location of the player is determined by location-based sensors GPS, which in turn determines the GUI behavior of the game. An integrated GUI and API testing tool can help resolve the first issue. An ability to pinpoint issues at the GUI or the API layer allows  GUI testers to cut down on intermediary steps. For instance, on realizing the issue is at the API layer, the GUI tester can reach out to the API developer without going to the GUI developer first. This saves testing time, which is critical in the case of mobile.
At the same time, to create a solid test automation strategy that scales, the focus should be on ensuring optimal behavior at GUI and API layer. This can be done by focusing on a test automation pyramid strategy, which is based on creating more unit tests, followed by API tests, and then fewer UI tests.
The game makers have big plans for this game post the worldwide launch, such as advertising and boosting retail traffic. The game is already creating news around how it is boosting foot traffic for local businesses and can even help sell houses. As this game becomes more important piece in the advertising industry, front end errors or usability issues wouldn’t be taken lightly.

Lesson #4: Prepare your app for all possible user scenarios

Just like every other app, gaming or not, no two users are alike. They access the app from different channels, different locations, and different devices but yet expect seamless performance. And they get easily frustrated when the app fails to do what they want it to do.
Irrespective of the problem, 9 out of 10 times they blame the app for their bad user experience. When I first got Pokemon Go, it drastically drained the battery on my Android. Even after trying the battery save mode for a few days, I eventually had to delete the game to make my phone usable again. Per Think with Google research, 72% users delete the app permanently after initial bad experience. While only 23% of the consumers give an app a second chance.
While negative out of the box experience slowing down the adoption may seem like a faraway problem for Pokemon Go right now, as the virality of the game calms down, it could be a deciding factor for Pokemon Go’s future.
I strongly think that the game makers are just getting started and there are some amazing things in store for the game makers and us as augmented reality games gain popularity. There are multiple possibilities for implementation and growth across all verticals using augmented reality, and Pokemon Go is doing a great job of giving us a taste of it. While we don’t know what the future of this game is, we hope that Pokemon Go makers are learning from each and every experience and those wishing to follow their success consider our tips for software quality.
Happy catching ‘em all!

Wednesday 27 July 2016

Cookie Testing


It simply refers to the testing of cookies, present at client side, in local machines or computers or browsers. But before, exploring the methods of the cookie testing, a little understanding of cookie would be gainful for understanding the working behind its testing.

What is Cookie?

A Cookie is basically an automatically generated file, which is stored at client's/ user's machines i.e. computer by the web server and is responsible for keeping the personalized information and data of the user. It is, generally stored in the hard drive of the computer.
It is a small file, with the maximum size of 4kb that records the activities, carried out by the user at the web server and at a later stage, this information log is being retrieved by the web browser, to establish the connection between different web pages.
It serves the purpose of maintaining the communication between the user and the web server. Its common use can be seen, in memorizing the user's e-mail address and password. In addition, cookies show their effectiveness in the implementation of the shopping cart, in personalized sites and user tracking.

Types of cookies

Generally, there are two types of cookies that resides in the user's system.
  • Session cookies: This type of cookie gets active on the call made by the web-browser and automatically gets deleted on the termination of the session by that web-browser.
  • Persistent cookies: These cookies reside permanently on the user's machine and have a specific time-period for the expiration, which may last for few months or year.

How it is tested?

The process of testing the cookies may be carried out through implementing following strategies

Deactivating the Cookies

It is one of the simplest ways of cookie testing. This method evaluates the working of major functional areas of the site, after disabling the cookies present on the web-browser. Either site may ask you to enable cookies on your browser or it may take some other alternative to work, on deactivation of the cookies.

Corrupting the Cookies

This method is carried out by editing the cookie data or its values, present at the site of local machines and providing it with random or invalid data. By editing the cookie data, one may gain access to internal and confidential data that may lead to hacking of the sites. Thus, it is an effective testing for the organizations, where data and information are considered very much sensitive, such as in banking system.

Rejecting the Cookies

What Is Manual Testing?

Manual Testing




In simplest terms, manual testing is the process in which a tester physically checks any new or improved product or software for defects and discrepancies. The tester, in this case, is a person who acts as an end-user to check and validate all the features. These checks are usually carried out on a test platform so that bug fixes can be done before the actual launch.
Manual testing is the first stage of testing that is done prior to launching or updating an existing product. It is also known as the primary testing stage as it sets course for the feasibility of automated testing.

Why Is Manual Testing Required?

Automation is a brainchild of human development. As such, it too suffers from certain restrictions that the human brain could not have thought of. Suffice to say it is impossible to do a 100% automatic testing. In order to make up for this deficit, manual testing is a more reliable tool. Depending on the size of business a company might undertake automated testing once it successfully completes manual testing.

Steps in Manual Testing

Manual testing is always conducted in a set format so as to reduce any chances of overlooking minor details. The 2 most commonly followed steps in manual testing are:
  • Manual Testing By Developer – This is normally the starting point of manual testing wherein the developer himself or any of his peers checks the internal working and the structure of the product or software. Any defects or discrepancies detected at this stage will involve revisiting the product or code in order to take corrective action.
  • Manual Testing by Tester – This is the second step, where a tester puts on the cap of an end user so as to see how the product works as a complete entity. In this step, the complete functionality of the product is examined closely so that the end user experience can be judged.

Advantages of Manual Testing

Manual testing is considered to be the least expensive and relatively less time-consuming way of authenticating the specifications and other requirements of the product or software before customer sign off can be gained. This is because automated testing involves the development of a test program which is an expensive task and time-consuming activity. Not only that but developing a test program is also subject to errors that need to be tested and corrected before it can be used.

Drawback of Manual Testing

In the absence of a comprehensive test plan, manual testing can give unreliable results due to human error at the testing stage. Overlooking even a small iota of information can give erratic outcomes. At such times, preference is given to a combination of manual and automated testing.

Future of Manual Testing

The point to remember is that no matter whatever course of action you decide to undertake, manual testing is and should be an integral part of your test plan. This is because automated testing follows a set plan and the results are expected within set variables, but manual testing gives that touch of the human element wherein the behavior of end-user guides the decisions. To eliminate manual testing is to one's own peril. After all, the reputation of your company and the success of your product depend on it.

Life Advice: How can I make my life simpler?

Life Advice: How can I make my life simpler? Originally Answered: What five tips can make one's life simpler?
What five tips can make one's life simpler?

1.) Get up early : Believe me, this is gonna work. Wake up early, go for running, do some push-ups. It will cost only an hour or two, but will surely build up a healthy 20 more years of your old age.

2.) Stop worrying : Thinking about the problem that MIGHT come, not only spoils your present, but also put some unwanted pressure at your mind, which makes you lazy from mind. If you simply look back at your past, you can easily reckon that most of the times you worried were just a wastage of time. Instead go and have some talk with your old friend over call or via messaging.

3.) Always make it a habit to write a diary at the end of each day. Its necessary for your self introspection.

4.)  Many a times you will be in a dilemma whether to do a particular thing or not. Stay calm. and think about its advantages and disadvantages. Think twice, and then pin it up for a final decision.

5.) Whenever angry, just make a countdown from 20 to 1 in your mind. and take a deep breathe with a smile. You yourself will forget where the anger disappear. Remember, whatever you build in 10 years, your anger destroys it in 10 mins.

Non-functional testing


Apart from proper and desirable functioning of the software, its performance under different and unexpected conditions, to meet the needs of the customers, is also a matter of concern. This, then arises the need of non-functional testing.

What is Non-functional testing?

Non-functional testing is a type of testing, performed, to check the non-functional traits and requirements of the software. It is done, to evaluate the effectiveness of the software, under variant and unforeseen conditions. It is the one common solution for the questions, related to software like:
  • How quickly, can it response?
  • How many users can simultaneously login into it?
  • If, it can be easily and quickly, adapted by new user? and many more…

What may be tested?

Unlike, functional testing, which is based on pre-defined requirements and specifications, non-functional testing focuses on customer's perspectives, like compatibility, maintainability, load capability, etc. This may includes:
  • Recovery of lost data or application.
  • Reliability and Scalability on different platforms, Operating systems, under variant environment.
  • Performance under stress.
  • Shortage of resources, such as memory.
  • Effectiveness, on simultaneous access to application by multiple users.
  • Security features.

Sub-Categories

Non-functional testing may be sub-classified under various testing methods as under:
  1. Availability Testing Availability Testing is an approach of testing the integrated system testing, contrary to, what is available for its operational requirements.
  2. Compatibility testing This type of testing is executed, to examine the compatibility features of the software, on multiple platforms, under variant environments, like operating system compatibility of the software.
  3. Configuration Testing It has to be seen, that the final product work seamlessly with the supported software and different hardware configuration available. Configuration testing takes care of that aspect.
  4. Compliance testing It is performed to check, whether the software product's performance doesn't deviates from the company's established standards.
  5. Installation Testing Also known as "implementation testing", is used to check desired functioning of the software, after its successful installation, along with, all necessary requirements.
  6. Documentation testing To examine the documentation artifacts, prepared before and during the testing phase, in order to assess the testing requirements, covers under documentation testing.
  7. Load testing It is, the simplest type of performance testing, that evaluates the performance & response of the software, under variant load factors.
  8. Endurance testing This involves, the testing of software's capability or durability to endure the huge and constant load, over a longer period of time.
  9. Localization and Internationalization testing The purpose of localization testing is to verify the quality of the software's local attributes, targeted for a particular population/culture/region, to ensure that the localized version works well for a particular region and meets the need of the targeted audience, whereas Internationalization testing, takes care of the uniform functionality of the software, across all geographical regions.
  10. Performance testing It is done, to examine the response, stability, scalability, reliability and other quality metrics of the software, under different workloads.
  11. Maintainability Testing Maintainability testing ensures the capability of the software, to get upgraded or modified, to meet the needs of the customer.
  12. Recovery testing It involves, wilful failure or crash of the software, to evaluate its ability of getting recovered, quickly.
  13. Security testing The intend of this testing, is to validate the security features of the software, so as to ensure, protection, authenticity, confidentiality and integrity of the information and data.
  14. Reliability Testing Covering load and feature testing under its belt, software reliability gives a measure of the lifecycle of the product, between two failures, and the time it takes to repair.
  15. Volume testing It is a type of performance testing, where software response and effectiveness is measured, by burdening it, with huge amount of data.
  16. Scalability testing Software should be scalable, along with the increase in load, number of concurrent users, data size, etc. This, arises the need of scalability testing, which is conducted to take care of scalability related issues, with the software.
  17. Usability testing It is performed, to ensure that software is user-friendliness and end-users, faces no issues, while using and handling the software product.
  18. Stress testing A type of performance testing, which emphasizes on robustness feature of the software product, by taking operational activities, beyond the boundaries.
Non-functional testing is important, as without verifying the interoperability across multiple platforms, maintainability, security, portability and other miscellaneous features, we cannot guarantee the readiness of software for its use.

Tuesday 26 July 2016

Speak 5 lines to YOURSELF Every Morning

    I am the Best.
    I can do it.
    God is always with me.
    I am a winner.
    Today is my day.


                                                                                 - Dr. A.P.J. Abdul Kalam

ALWAYS LEAVE OFFICE ON TIME

Love your job

but don’t love your company,

because you may not know

when your company

stops loving you.

- Dr. APJ Abdul Kalam

ALWAYS LEAVE OFFICE ON TIME

  1. Work is a never-ending process. It can never be completed.

  2. Interest of a client is important,so is your family.

  3. If you fall in your life, neither your boss nor client will offer you a helping hand; your family and friends will.

  4. Life is not only about work, office and client. There is more to life.

  5. You need time to socialize, entertain, relax and exercise. Don’t let life be meaningless.

  6. A person who stays late at the office is not a hardworking person. Instead he/she is a fool who does not know how to manage work within the stipulated time. He/She is inefficient and incompetent in his work.

  7. You did not study hard and struggle in life to become a machine.

  8. If your boss forces you to work late, he/she may be ineffective and have a meaningless life too; so forward this to him/her.


Leaving Office on Time:
Efficient
Good Social Life
Quality Family Life


Leaving Office Late:
Inefficient & Incompetent
No Social Life
Less Family Life

 

Wednesday 20 July 2016

21 inspiring quotes by albert einstein


  1. Try not to become a man of success, but rather try to become a man of value.

  2. In the middle of difficulty lies opportunity.

  3. A person who never made a mistake never tried anything new.

  4. Only a life lived for others is a life worthwhile.

  5. Life is like riding a bicycle. to keep your balance you must keep moving.

  6. Imagination is more important than knowledge.

  7. Weakness of attitude becomes weakness of character.

  8. Great spirits have always encountered violent opposition from mediocre minds.

  9. It is not that i am so smart, it's just that i stay with problems longer.

  10. Insanity is doing the same thing, over and over again and expecting different results.

  11. Logic will get you from A to B. imagination will take you everywhere.

  12. You have to learn the rules of the game and then you have to play better than anyone else.

  13. We cannot solve our problems with the same thinking we used when we created them.

  14. The only source of knowledge is experience.

  15. You never fail until you stop trying.

  16. Once we accept our limits we go beyond them.

  17. A ship is always safe at shore but that is not what it is built for.

  18. If you want to live a happy life, tie it to a goal, not to people or things.

  19. Only those who attempt the absurd achieve the impossible.

  20. It is better to believe than to disbelieve; in doing you bring everything to the realm of possibility.

  21. Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.

Monday 18 July 2016

5 things to do before an interview


Review
Ensure you are familiar with the points mentioned in your resume. Highlight the important points and milestones which you would like to explain in detail at the interview discussion.











Prepare in advance
Be ready for common questions, including "tell us about yourself, what do you know about the company, what are your interests, reasons for leaving previous or existing job". This will avoid fumbling during the interview.






Rehearse
Besides preparing for common questions, practice the right sitting posture, body language and rehearse on how would you enter and greet the interviewers.









Documentation
Collect all your necessary documents and put in a sequential manner to avoid spilling them all over the floor when the interviewer asks for them.







Check
This should be your last step before entering the interview hall - use the restroom and check yourself in the mirror. Gather your thoughts and focus on the interview.










You can also suggest your points in comment line. So, Reader can get idea before got to interview

Remove Ads from skype

The following steps will help to remove Ads from your skype The following steps will help to remove Ads from your skype:

Step1:
From Control Panel, Click on Internet Options, Click on the Security tab and select the Restricted Sites icon.
Press the Sites button and type apps.skype.com in the text box, then press Add.

Step 2:
Remove the Ad Placeholder
go to the path C:\Users\Your Username\AppData\Roaming\Skype.
Note:- AppData is a hidden folder. So you need to give the above path in explorer
You’ll then need to open the folder that’s titled with your Skype ID and find an XML file called config. Right-click that file and choose to open it with Notepad.
Press Ctrl + F to use the Find function to search for AdvertPlaceholder. You should find a piece of code that reads <AdvertPlaceholder>1</AdvertPlaceholder> — change that 1 to a 0 and you will remove the placeholder from your Skype interface.

Restart Skype for the changes to take effect
Software tools provided by Qualcomm

Friday 15 July 2016

Convert RAW Audio into mp3 Encoded Audio using FFMPEG

Download lame Source code

Header File
#include "armffmpeg/lame/include/lame.h"

Variables
int pcm_samples_2d[2][RAWBUFSIZE];
lame_global_flags *mp3;

numBytes = RAWBUFSIZE;

Init lame flags.
mp3 = lame_init();
if(!mp3) {
        printf("Unable to initialize mp3 object.");
} else {
        printf("Able to initialize mp3 object.\n");
}

/* set other parameters.*/
lame_set_num_channels(mp3, 1);
/*lame_set_num_samples(mp3, (nSecondsAudio * sampleRate));*/
lame_set_in_samplerate(mp3, gAudSampleRate);
lame_set_quality(mp3, 5);  /* set for high speed and good quality. */
lame_set_mode(mp3, 3);  /* the input audio is mono */

lame_set_out_samplerate(mp3, gAudSampleRate);
lame_set_VBR(mp3, vbr_default);
printf("Able to set a number of parameters too.");
framesize = lame_get_framesize(mp3);
printf("Framesize = %d\n", framesize);

/* set more internal variables. check for failure.*/
if(lame_init_params(mp3) == -1) {
        printf("Something failed in setting internal parameters.");
}

Encode mp3 From RAW Data

memset(pcm_samples_2d[1], 0, (numBytes/2) * sizeof(int));
memset(pcm_samples_2d[0], 0, (numBytes/2) * sizeof(int));
i = 0;
for(i = 0; i < (numBytes/2); i++) {
        pcm_samples_2d[0][i] = *((int *)InAudioBuf + i);
}
encodedBufferSize = lame_encode_buffer(mp3, (const short int *)pcm_samples_2d[0], (const short int *)pcm_samples_2d[1],
                numBytes/2, OutAudioBuf, numBytes/2);


Close Lame module
lame_close(mp3);

FLV Audio File Format

Audio Tag

FLV Audio Data Format
0 = Linear PCM, platform endian
1 = ADPCM
2 = MP3
3 = Linear PCM, little endian
4 = Nellymoser 16-kHz mono
5 = Nellymoser 8-kHz mono
6 = Nellymoser
7 = G.711 A-law logarithmic PCM
8 = G.711 mu-law logarithmic PCM
9 = reserved
10 = AAC        //Sampling Rate 3 for AAC
11 = Speex
14 = MP3 8-Khz
15 = Device-specific sound

Sample Rate

0 = 5.5-kHz
1 = 11-kHz
2 = 22-kHz
3 = 44-kHz

Sound Size
0 = snd8Bit
1 = snd16Bit

Audio Type
0 = sndMono
1 = sndStereo

Convert RAW Audio into AAC Encoded Audio using FFMPEG

AAC - Advanced Audio Codec.

Download FAAC Source code from https://sourceforge.net/projects/faac/

Header File
<faac.h>

Variables
faacEncHandle codec;
faacEncConfigurationPtr conf;
unsigned long* one;
unsigned long* two;

Initialize and configure faac

/* AAC Audio FFMPEG */
one = (unsigned long *)calloc(1,((sizeof(unsigned long))+(32 - 1))/(32)*(32));
if (one == NULL)
{
        printf("Failed to allocate audio output buffer\n");
        return;
}
two = (unsigned long *)calloc(1,((sizeof(unsigned long))+(32 - 1))/(32)*(32));
if (two == NULL)
{
        FREE(one)
                printf("Failed to allocate audio output buffer\n");
        return;
}

codec=faacEncOpen(SampleRate, 1, one, two);
if(!codec){
        printf("Something went wrong");
        FREE(one)
                FREE(two)
                return;
}

conf=faacEncGetCurrentConfiguration(codec);

/* Here you can change configure as per your Requirment
**
MPEG ID's
MPEG2 1
MPEG4 0

AAC object types
MAIN 0
LOW  1
SSR  2
LTP  3

Input Formats
FAAC_INPUT_NULL    0
FAAC_INPUT_16BIT   1
FAAC_INPUT_24BIT   2
FAAC_INPUT_32BIT   3
FAAC_INPUT_FLOAT   4
*/
conf->inputFormat = FAAC_INPUT_16BIT;
conf->mpegVersion=MPEG4;
conf->aacObjectType=SSR;

faacEncSetConfiguration(codec,conf);

Call Encoder APIs to Encode AAC from RAW Audio

gAudInBuf = (unsigned char *) malloc(4000);
if (gAudInBuf == NULL)
{
        printf("Failed to allocate audio input buffer\n");
        break;
}


vdSize=faacEncEncode(codec,(int*)gAudInBuf, *one, adBuffer, *two);

Close faac Encoder module and Free Memory

faacEncClose(codec);
FREE(one)
FREE(two)

RAW to G711(μ-Law) encoding algorithm

/* ===================================================================
 *  @func     ALG_G711ulawEncode
 *
 *  @desc     G711 Encode
 *
 *  @inputs   This function takes the following inputs
 *            src - RAW data buffer
 *            bufsize - Size of RAW data
 *
 *  @outputs  dst - G711 encoded Data
 *
 *  @return   Size of Encoded Data
 *  ==================================================================
int ALG_G711ulawEncode(short *dst, short *src, Int32 bufsize)
{
    unsigned short i;

    short data;

    unsigned short isNegative;

    short nOut;

    short lowByte = 1;

    int outputSize = bufsize / 2;

    for (i = 0; i < outputSize; i++)
    {
        data = *(src + i);
        data >>= 2;
        isNegative = (data < 0 ? 1 : 0);

        if (isNegative)
            data = -data;

        if (data <= 1)
        {
            nOut = (char) data;
        }
        else if (data <= 31)
        {
            nOut = ((data - 1) >> 1) + 1;
        }
        else if (data <= 95)
        {
            nOut = ((data - 31) >> 2) + 16;
        }
        else if (data <= 223)
        {
            nOut = ((data - 95) >> 3) + 32;
        }
        else if (data <= 479)
        {
            nOut = ((data - 223) >> 4) + 48;
        }
        else if (data <= 991)
        {
            nOut = ((data - 479) >> 5) + 64;
        }
        else if (data <= 2015)
        {
            nOut = ((data - 991) >> 6) + 80;
        }
        else if (data <= 4063)
        {
            nOut = ((data - 2015) >> 7) + 96;
        }
        else if (data <= 7903)
        {
            nOut = ((data - 4063) >> 8) + 112;
        }
        else
        {
            nOut = 127;
        }

        if (isNegative)
        {
            nOut = 127 - nOut;
        }
        else
        {
            nOut = 255 - nOut;
        }

        // Pack the bytes in a word
        if (lowByte)
        {
            *(dst + (i >> 1)) = (nOut & 0x00FF);
        }
        else
        {
            *(dst + (i >> 1)) |= ((nOut << 8) & 0xFF00);
        }

        lowByte ^= 0x1;
    }

    return (outputSize);
}

G711(μ-Law) to RAW decoding Algorithm

/* ===================================================================
 *  @func     AUDIO_audioDecode
 *
 *  @desc     Function does the following
 *
 *  @inputs   This function takes the following inputs
 *            src - G711 data buffer
 *            bufsize - Size of G711 data
 *
 *  @outputs  dst - RAW Data
 *
 *  @return   SUCCESS
 *  ==================================================================
 */
int AUDIO_audioDecode(char *src, short *dst,
                      int bufsize)
{
    int sizeConsumed = 0, i = 0;

    sizeConsumed = bufsize;

    for (i = 0; i < sizeConsumed; i++)
    {
        *((unsigned short *) (dst) + i) =
            ALG_G711ulawDecode(*((unsigned char *) (src) + i));
    }
   
    return TRUE;
}

/* ===================================================================
 *  @func     ALG_G711ulawDecode
 *
 *  @desc     Decode G711 Audio
 *
 *  @inputs   This function takes the following inputs
 *            input - G711 data
 *
 *  @return   RAW Data
 *  ==================================================================
 */
short ALG_G711ulawDecode(unsigned short input)
{
    unsigned short isNegative;

    short nOut;

    isNegative = ((input & 0x80) == 0);
    if (isNegative)
        nOut = 127 - input;
    else
        nOut = 255 - input;
    if (nOut < 2)
        nOut *= 2;
    else if (nOut < 16)
        nOut = ((nOut - 1) << 1) + 1 + 1;
    else if (nOut < 32)
        nOut = ((nOut - 16) << 2) + 2 + 31;
    else if (nOut < 48)
        nOut = ((nOut - 32) << 3) + 4 + 95;
    else if (nOut < 64)
        nOut = ((nOut - 48) << 4) + 8 + 223;
    else if (nOut < 80)
        nOut = ((nOut - 64) << 5) + 16 + 479;
    else if (nOut < 96)
        nOut = ((nOut - 80) << 6) + 32 + 991;
    else if (nOut < 112)
        nOut = ((nOut - 96) << 7) + 64 + 2015;
    else
        nOut = ((nOut - 112) << 8) + 128 + 4063;
    if (isNegative)
        nOut = -nOut;
    nOut <<= 2;
    return nOut;
}

Thursday 14 July 2016

Linux - RPM

if rpm is not installed in your machine, follow below step

sudo apt-get install rpm

RPM is one of the tool for linux package installation. Below are some useful commands

1. Install to default folder

rpm -i packagename.rpm

2. Install with Relocation

rpm -i --prefix=/ur/path packagename.rpm

3. Check whether a rpm package can be relocated

rpm -qpi packagename.rpm | grep Relocations

4. Check for installed package in machine

rpm -qa | grep packagename

5. Uninstall a package

rpm -e packagename

6. Upgrade a package

rpm -U packagename.rpm